您好我有一個SQL查詢,我堅持一個條件,因爲我是新來sql
將JOIN中的條件轉移到SQL中的下一個JOIN?
select * from Today
LEFT JOIN
TABLEPricing Yesterday ON
Yesterday.Date = (select top 1 date from #Dates where MONTH(DATE) = MONTH(Today.Date)-1 AND YEAR(DATE) = YEAR(Today.Date))
LEFT JOIN Prev ON
Prev.Date = Yesterday.Date
在第二個條件Prev.Date = Yesterday.Date
將Yesterday.Date
採取先前自動分配表達式Yesterday.Date
像Yesterday.Date = (select top 1 date from #Dates where MONTH(DATE) = MONTH(Today.Date)-1 AND YEAR(DATE) = YEAR(Today.Date))
或我需要再次指定如下所示的相同條件。
Prev.Date = (select top 1 date from #Dates where MONTH(DATE) = MONTH(Today.Date)-1 AND YEAR(DATE) = YEAR(Today.Date))
請澄清我很困惑。
更新的問題我錯過了它 – Neo 2013-04-24 08:13:52