I have two columns
val year
10 2012
50 2012
20 2011
30 2011
I need like
60 2012
50 2011
How to group by year and sum the values
tried using sum(val) but couldn't achieve the need result
This way
declare @tmp table(Value integer, Year integer) insert into @tmp select 10,2012 union all select 50,2012 union all select 20,2011 union all select 30,2011 select sum(Value) Sum, Year from @tmp group by Year
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.