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
Benefits of Stored Procedures?
What are the approximate numeric data types?
Do you know clustered and non-clustered index?
What is use of attribute hierarchy optimized state? : sql server analysis services, ssas
What are the types of database schema? : sql server analysis services, ssas
What happens to a trigger with multiple affected rows?
What is isnull() operator?
Which is the best place or learning center for MS SQL?????In Bangladesh?????
What are ddl triggers and types of ddl trigger?
What are the database roles? : sql server security
What is partitioned view?
How do I partition a table in sql server?
How to modify existing triggers using "alter trigger"?
Can we do dml on views?
What is the use of custom fields in report?