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
How to find the version of sql server? : sql server database administration
What are locks in sql?
What is a benefit of using an after insert trigger over using a before insert trigger?
how to create “alternate row colour”?
What is sql server 2000 work load governor?
When would you use it?
What is open database communication (odbc)?
Give some Scenario for Non Clusterd index? Can we write system defined functions in side The Function? Wat is the Unique Datatype?
What is scheduled job and how to create it?
What are the disadvantages of using the stored procedures?
What is the optimal disk configuration for a database server and what raid configurations would you use if budget is not a constraint?
Define full outer join in sql server joins?
What is the largest component inside a field?
How to insert data with null values?
What happens when converting big values to numeric data types?