Generates totals that appear as additional summary columns at the end of the result set. When used with BY, the COMPUTE clause generates control-breaks and subtotals in the result set.
USE Database;
GO
SELECT CustomerID, OrderDate, SubTotal, TotalDue
FROM Sales.SalesOrderHeader
WHERE ID = 1
ORDER BY OrderDate
COMPUTE SUM(SubTotal), SUM(TotalDue);
USE Database;
GO
SELECT CustomerID, OrderDate, SubTotal, TotalDue
FROM Sales.SalesOrderHeader
WHERE ID = 1
ORDER BY OrderDate
COMPUTE SUM(SubTotal), SUM(TotalDue);
how do you access in c#?
ReplyDeletefor this query it will return two table ...
Deletefirst table contains all data CustomerID, OrderDate, SubTotal, TotalDue....
second table contains total sums of SubTotal and TotalDue
means first table u can directly bind to your grid
second table's two sums can you put in footer row as sums of respective columns...
Ex:---
griedview.datasource=ds.table[0];
griedview.databind();
griedview.HeaderRow.cell[2].text= ds.table[1].rows[0]0].tostring();
griedview.HeaderRow.cell[3].text= ds.table[1].rows[0]1].tostring();