我有两个查询加入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