i want a procedure without using cursors so that my ouptut is as below:(if possible i want the query using with operator)
(comments are locked)
|
|
TSQL wont give you great formatting on this, for that you are better using your UI to do the maths and then format the result - SSRS will calculate group totals and so on with great style and simplicity. In TSQL you could use the follow to give roughly what you suggest:
(comments are locked)
|
|
As Jonathan said, you're better off using SSRS for the presentation part. In case you'd like to get all the data you need in just one recordset, have a look at the following query: For more info on how to use the OVER clause to aggregate data, have a look at this article: http://blog.hoegaerden.be/2010/06/01/aggregating-data-with-the-over-clause/ BTW: it's not a good idea to name your columns "time" or "date". Those are data types nowadays. Even if you're currently on 2005, it's better to avoid them now so that you won't run into issues when upgrading.
(comments are locked)
|

