Home > DeveloperSection > Forums > How to Calculate Column Summary in sql server.
Ankit Singh

Total Post:341

Points:2389
Posted on    January-12-2016 10:25 PM

 C# SQL Server  SQL  SQL Server 2008  SQL Server 2012 
Ratings:


 1 Reply(s)
 348  View(s)
Rate this:
I want to  Use Calculate Column Summary in sql server. How to do this please help me.


aditya kumar Patel

Total Post:246

Points:1752
Posted on    January-12-2016 10:28 PM

declare @table table(Name varchar(100), Amount decimal(12,2))

insert into @table

select 'arjun', 3000 union all

select 'pawan', 2000 union all

select 'rahul', 3000 union all

select 'rahul', 2500 union all

select 'pawan', 2300 union all

select 'arjun', 2400

select Name, SUM(amount) as amount from @table

group by name

union all

select 'Total',SUM(amount) from @table

 


Don't want to miss updates? Please click the below button!

Follow MindStick