次の 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
個別に実行すると、両方のクエリが値を返すようになりました。しかし、それらを一緒に実行すると、2 番目のクエリのレコードが表示されA3DuplexPagesPrinted
、A3DuplexTotalCost
.
何故ですか?