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 / murali krishna reddy

SELECT A.YEAR, (SELECT SUM(AMT) FROM ACCOUNT WHERE YEAR <=
A.YEAR) AS AMT
FROM ACCOUNT AS A GROUP BY A.YEAR

How about this?

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we call UDF(User Define Function) using C# code in ASP.net ?

6366


Explain what stored procedure sp_replcounters is used for? : sql server replication

1236


as a part of your job, what are the dbcc commands that you commonly use for database maintenance? : Sql server database administration

646


Give me any three differences between Truncate and Delete.

759


Are connections to sql server encrypted?

746






which backup strategy you are following at ur company

1932


Can group by be used without aggregate functions?

677


What is Federation and Federation Member?

90


what is the primary use of the model database? : Sql server administration

727


what information is maintained within the msdb database? : Sql server administration

700


How can i Relate Tables in SSIS

806


Explain the third normal form(3nf)?

700


What is the difference in accessing db between sql server vs sql azure?

166


What is named calculation? : sql server analysis services, ssas

730


Types of Authentications in Sql Server? How user gets authenticated through windows authentication?

758