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
Give a example to search fr a string in all stored procedure in sql server.
Explain what is meant by replication of database?
What is the difference between ddl,dml and dcl commands?
How to create a user name in a database?
How do I perform an unattended install of sql server 2000?
What is the order in which the sql query is executed?
Do you have any idea about the tcl commands?
What is dirty page?
What is dml command?
What do you mean by a Composite primary key?
What is scalar user-defined function?
how to create “alternate row colour”?
What program is used to store the data source file?
What are a scheduled jobs or what is a scheduled tasks?
What is a natural primary key?