Hello all,
I have data like :-
year amt
2004 10
2005 20
2006 30
Now i want output as:-
2004 2005 2006
10 30 60
but i have to use here group by on year.So, i need a single
query within that i can find.
Answer Posted / sagun sawant
select ((select sum((case when year = '2004' then (amt)
else 0 end)) from account )) as [2004]
,((select sum((case when year = '2005' then (amt)
else 0 end)) from account )) as [2005]
,((select sum((case when year = '2006' then (amt)
else 0 end)) from account )) as [2006]
| Is This Answer Correct ? | 2 Yes | 2 No |
Post New Answer View All Answers
What are different type of Collation Sensitivity?
How many replicas are maintained for each SQL Azure database?
Difference between Inner vs outer joins?
What is function of CUBE ?
Do you know what is a linked server in sql server?
What are Row versions of DataRow?
how can you check the level of fragmentation on a table? : Sql server administration
what is the information that can be stored inside a bit column? : Sql server database administration
What is dml command?
What is field with example?
Explain about SQLOS?
Explain the properties of a relational table?
What is default constraint in ms sql server?
Can we add our custom code in ssis?
What do you understand by physical_only option in dbcc checkdb?