我有兩個查詢加入union All
。聯盟ALL取空行
SELECT select 'Finished' AS Status,amount AS amount,units As Date
from table1 WHERE Pdate > cdate AND name [email protected]
UNION ALL
SELECT select 'Live' AS Live,amount,units
from table1 Where Pdate = cdate And name [email protected]
結果
Status amount units
Finished 100 20
Live 200 10
當任一查詢取空集,我只得到一個行,如果兩者取空集,然後我沒有行
所以,我怎樣才能得到像這
Status amount Units
Finished 100 20
Live 0 0
OR
Status amount Units
Finished 0 0
Live 200 10
OR
Status amount Units
Finished 0 0
Live 0 0
感謝。
您選擇單位的日期和「活」的活。這不應該是單位作爲單位和「現場」狀態? – Dan 2012-07-11 12:41:40