Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the advantages dts has over bcp?

979


What are three major types of constraints?

1096


What is catalog views?

1057


What is mssql?

975


When cursors are useful?

1080


Tell me what do you understand by a view? What does the with check option clause for a view do?

997


tell me what are the steps you will take to improve performance of a poor performing query? : Sql server database administration

1006


What is forward - only cursors / read only cursor?

1072


In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram

1987


How to assign null values to variables or columns?

956


How to test subquery results with the exists operator?

1086


What is the security principal at the server level that represents your session?

1000


What happens if strings are casted into wrong code pages in ms sql server?

1098


What are three ways you can use an identity value inside a trigger? Why would you prefer one way over another?

978


How is SQL Azure different than SQL server?

223