Hi,
I have a data similar to this :
saledate >> item >> qty
01.10.2011 >>> pen >> 23
01.10.2011 >>> pencil >> 55
02.10.2011 >> stick >> 45
03.10.2011 >> fevistick >> 25
03.10.2011 >> paper >> 55
04.10.2011 >> magic paper >> 33
04.10.2011 >> small paper >> 21
Now when I put the following code
Code:
select saledate, sum(qty)
from table
GROUP BY saledate
UNION ALL
select 'total' as saledate, sum(qty)
from table
GROUP BY total
The output is
saledate >> qty
01.10.2011 >> 78
02.10.2011 >> 45
03.10.2011 >> 80
04.10.2011 >> 54
total >> 257
But I want subtotal at the bottom of 2nd date and 4th date like below : how is it possible?
saledate >> qty
01.10.2011 >> 78
02.10.2011 >> 45
total >> 123
03.10.2011 >> 80
04.10.2011 >> 54
total >> 134