可以說今天的日期是2014年1月22日 並且我運行的報表具有下表(表),但是2014年1月1日至2014年1月18日的SIdate 的輸入範圍。如何創建一個sql腳本來考慮兩列?
我想根據我輸入的SIdate顯示所有行,這是2014年1月1日至2014年1月18日的日期,但CMdate也應該考慮並且應該通過日期參數。
正如你在表2(我的期望輸出)已經注意到,第6行是不存在了bcore CMdate是2014年1月21日
表1
Emp SIDate item TotQty TotAmt CMDate CMAmt
-------------------------------------------------------
CLO 01-01-14 item1 120 1500.00 null null
CLO 01-02-14 item2 80 500.00 01-05-14 20.00
CLO 01-05-14 item6 21 1100.00 null null
CLO 01-10-14 item5 100 2000.00 01-10-14 200.00
CLO 01-12-14 item9 300 100.00 null null
CLO 01-16-14 item3 150 650.00 01-21-14 150.00
表2(所需的輸出)
Emp SIDate item TotQty TotAmt CMDate CMAmt
-------------------------------------------------------
CLO 01-01-14 item1 120 1500.00 null null
CLO 01-02-14 item2 80 500.00 01-05-14 20.00
CLO 01-05-14 item6 21 1100.00 null null
CLO 01-10-14 item5 100 2000.00 01-10-14 200.00
CLO 01-12-14 item9 300 100.00 null null
任何輸入將非常感激。
所有回答做了很大的幫助。謝謝大家:) – user1840952