我有以下 SQL 查询:
select (case when len(GroupName) = 0 then 'Unknown' else GroupName end) as GroupName
,PaperId,Color,Duplex, sum(Page_Printed) As A3PagesPrinted, sum(Cost) as A3TotalCost
from printstat where paperid = 8 and color = 0 and duplex = 0
and Date_Print >= '2013-01-01' and Date_Print < '2013-10-21'
group by GroupName, PaperId, Color, Duplex
union all
select (case when len(GroupName) = 0 then 'Unknown' else GroupName end) as GroupName
,PaperId,Color,Duplex, sum(Page_Printed) As A3DuplexPagesPrinted,
sum(Cost) as A3DuplexTotalCost from printstat where paperid = 8 and color = 0
and duplex = 1 and Date_Print >= '2013-01-01' and Date_Print < '2013-10-21'
group by GroupName, PaperId, Color, Duplex
现在,两个查询在单独运行时都返回值。但是当我一起执行它们时,我的第二个查询的记录会显示出来A3DuplexPagesPrinted
,并且A3DuplexTotalCost
.
这是为什么?