This is something you are better off doing at the presentation layer. Front-end tools especially reporting software can do this much better at that end, doing this in SQL can be tricky and messy.If you still need to do it in SQL Server - there are many ways to do it in SQL, just depends on what suits you best. Do you have any grouping in the statement? If you do then WITH ROLLUP is the easiest way of doing it: select orderid, sum(unitprice) from [order details] where orderid < 10260 group by orderid with rollup
If you dont, you can use the COMPUTE clause to return the Grand total, but that will be returned as a different resultset: select unitprice from [order details] where orderid < 10260 compute sum(unitprice)
The best way, in my opinion is to do use a UNION with an aggregation query:select orderid, unitprice from [order details] where orderid < 10260 UNION ALLselect NULL, SUM(unitprice) from [order details] where orderid < 10260
OS