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 / pradip jain

Pivot concept can be use

please correct this as it it near to correct.


SELECT
[2004] '2004',
[2005] '2005',
[2006] '2006'
FROM
(select year,amt from dbo.Pivot1) s
PIVOT
(
sum(amt )
FOR year IN ([2004],[2005],[2006])
) p


output is

2004 2005 2006
10 20 30

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is updatable resultset?

1008


Difference between primary key and clustered index?

1010


What is the maximum size of column in sql server?

893


What are the different type of replication in sql server?

981


How to move database physical files in ms sql server?

1034


What is faster join or union?

1213


What are the different types of collation sensitivity in sql server?

1113


What are cursors stored procedures and triggers?

1021


What is the use of keyword with encryption.

1030


What are wait types?

1118


What is intellisense?

1053


What are the extra roles available in msdb? : sql server security

1135


What samples and sample databases are provided by microsoft?

1038


OPTIMIZATION OF SP,CURSOR,TRIGGERS

2785


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

2010