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

Is there any difference between the primary key and unique key?

950


Is truncate autocommit?

898


What does set rowcount do?

867


What is log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.

2714


What is the partitioning method?

975


How to copy data from one table to another table?

935


Why functions are used in sql server?

898


How can we check the sql server version?

983


Which command is used for user defined error messages?

1010


1.how to find the dead lock in sql server? 2.How to fine the memory leaks in sql server? 3.suppose transaction log file increasing what action will take ?

1967


What are system databases into sql server (2005/2008) : sql server database administration

967


What is parameterized reports in ssrs ?

141


What are blobs, tables, and Queues? Is SQL is the standard way to query blobs, tables, and queues?

135


Explain what are the database objects? : SQL Server Architecture

1006


What is the use of tempdb? What values does it hold?

1003