Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-12-02 : 08:23:37
|
| bharat writes "Hi I have a table which has in addition to others two columns "budget" and "description". The table has table id which is 14 digit number stored as string, It also have Account Type which can have values of 'H', 'C', 'S', 'L'. 'H' represents a fund and 'C' are departments under the fund and 'S' is subdepartment under department and 'L' is line items under 'S'. The total of L's comes up to S, total of S's comes up to C and total of C's come up to H. there are 41 unique 'H' under which there are C, S and L's. the description column has the name of each fund, department, subdepartment and line items needless to say they are all unique. I want to be able to show totals by account type ie. by 'H', 'C', 'S' and 'L'. I know I can use the Sum function which will total all 'L's' under an 'H' roll it up and give me a sum however it will not extract the description from the corrosponding 'H' description column to display against the sum. To be more clear if i sum by acct type = 'H' I need to see the following:ID Sum Description12343567890000 10000 CURRENT ACCOUNTthey are stored asID acct_type budget Description12343567890000 H 0.00 CURRENT ACCOUNT12343567891100 C 0.00 Curr Acc --Uniform12343567891111 S 2500 School Uniforms12343567891112 S 2500 Mason Uniforms12343567891200 C 0.00 Curr Acc--Outdoor12343567891211 S 5000 Wall repairI want to add all the 'S' under each 'H' display the ID and the description (Current Account). any stored procedure or anything else to do this? I have not dound anything." |
|
|
|
|
|