好日子,例如:用這些給定的數據從我的查詢中獲得。SQL 2008:如果一行中的2列具有這些值,則排除行
T0.Date T0.customer T0.total T1.Date, T1.Total
2.1.2017 BLABLA 2,400.00 3.8.2017 2,400.00
1.2.2017 BLOBLO 5,000.00 3.1.2017 5,000.00
1.1.2017 BLEBLE 3,000.00 2.5.2017 3,000.00
12.5.2016 BLABLA 1,000.00 1.25.2017 1,000.00
我怎麼可能獲得與T0.Date =一月(1),並在同一行刪除行的想法,T1.Date =月(3)進入查詢。我正在考慮在where子句中使用case,但我不知道如何開始條件。不過,如果T1.Date =月(2),不要緊,如果T0.Date = 1或過去幾年月(2016年1月12日)..
UPDATE: 預期輸出:
T0.Date T0.customer T0.total T1.Date, T1.Total
2.1.2017 BLABLA 2,400.00 3.8.2017 2,400.00
1.1.2017 BLEBLE 3,000.00 2.5.2017 3,000.00
12.5.2016 BLABLA 1,000.00 1.25.2017 1,000.00
問題尚不清楚。你能否用預期產出清楚解釋清楚? –
就像T1.Date進行中一樣,它不會允許T0.Date是一月。但是,如果T1.Date是2月份,則可以在1月份日期和下面(2016年)下載T0.Date。 – aintno12u