1

I'm trying to combine two queries together to give a combined stacked table with one common total eg QTY.

I don't want the dates to de-dupe & I need the columns to keep separated,l but want the Qty column combined if possible.

I tried 'union' but to no avail as it stacks directly above and the value are different formats.

enter image description here

Can anyone help? ;-)

4

1 回答 1

2
SELECT t.* FROM (
    SELECT [Date], [Eggs], NULL [Colour], [Qty] FROM Table1
    UNION ALL
    SELECT [Date], NULL [Eggs], [Colour], [Qty] FROM Table2
) t ORDER BY t.[Date]
于 2013-08-01T15:18:32.443 回答