我有一个这样的查询:
SELECT * FROM (
SELECT id, SUM( orderLineTotal ) as orderLine1, NULL as orderLine 2
FROM Orders
WHERE Orders.Date < @Today
GROUP BY id
UNION
SELECT id, NULL as orderLine1, SUM(orderLineTotal2) as orderLine 2
FROM Orders
WHERE Orders.Date = @Today
GROUP BY id
) o
GROUP BY o.id, o.orderLine1, o.orderLine2
我得到了这样的结果:
ID OrderLine1 OrderLine2
-----------------------------------------
1 105.00 NULL
1 NULL 204.00
2 49.30 NULL
2 NULL 94.24
有没有办法修改查询以返回这样的内容?
ID OrderLine1 OrderLine2
-----------------------------------------
1 105.00 204.00
2 49.30 94.24