I have a query;
select ProductID, name, (unitPrice*quantity) As 'Stock Equity'
from tproduct
group by productID with rollup
;
I wish for this to return a set of rows with the last being a calculation of the Total, instead its repeating the last result?
can anyone tell me why and how to overcome this please?
this is the query result at the moment;
ProductID Name Stock Equity
1 cannon 600 D 3360
2 cannon 550 D 1000
3 cannon 500 D 750
4 cannon 5D 5000
5 cannon 650 D 9000
6 Nikon D5100 1000
7 Nikon D3200 420
8 Nikon D7000 2700
9 Nikon D800 6030
10 Nikon D90 4770
null Nikon D90 4770
You can use
UNION ALL:See SQL Fiddle with Demo
Or you can use something like this:
See SQL Fiddle with Demo