トランザクション (a) と価格 (b) の 2 つのテーブルがあります。テーブル b から取引日に有効な価格を取得したいと考えています。
テーブル a には商品取引の履歴が含まれています: Store_type、Date、Article、...
テーブル b には商品価格の履歴が含まれています: Store_type、Date、Article、price
現在、私はこれを持っています:
Select
a.Store_type,
a.Date
a.Article,
(select b.price
from PRICES b
where b.Store_type = a.Store_type
and b.Article = a.Article
and b.Date = (select max(c.date)
from PRICES c
where c.Store_type = a.Store_type
and c.Article = a.Article
and c.date <= a.date)) AS ART_PRICE
from TRANSACTIONS a
正常に動作しますが、二重サブクエリのために非常に時間がかかるようです。LEFT JOINでも同じことができますか?