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
What is updatable resultset?
Difference between primary key and clustered index?
What is the maximum size of column in sql server?
What are the different type of replication in sql server?
How to move database physical files in ms sql server?
What is faster join or union?
What are the different types of collation sensitivity in sql server?
What are cursors stored procedures and triggers?
What is the use of keyword with encryption.
What are wait types?
What is intellisense?
What are the extra roles available in msdb? : sql server security
What samples and sample databases are provided by microsoft?
OPTIMIZATION OF SP,CURSOR,TRIGGERS
In one interview...interviewer ask me question pleas tell me sql server architecture.. can any body tell me the sql server architecture with digram