Summarizing of column values in SQL Server
Hi friends ,
here I am wondering about sql server by reading " ROLLUP " concept in SQL Server.
Consider the scenario which gives you sum of columns within query , Is it possible ?
Before reading it , I used different methods for summation of columns but Its tooo good to read it that , we will get sum in practicle way within query itself.
Highlighted row will be sum of RegId and Amount column.
Query as :
SELECT O_Id,Sum([OrderNo]) as RegId, SUM([p_id]) as TotalAmount
AS Amount FROM [testdb1].[dbo].[Orders]
GROUP BY O_Id
WITH Rollup
Order_Id RegId TotalAmount 1 21 2
2 2324 1
3 32 2
5 6 3
NULL 2383 9 <---Here Summary of Column (Regid ,TotalAmount)
I am searching more about Rollup,Cube and other related concept . Till date you also search and inform me more.
Try it..!! Enjoy...
Comments
Post a Comment