count and new column

  • After doing all the joins my final result set is something like this

    This has records description, count column

    Rerecords Description Count

    Bank Records 50

    Hospital Records 100

    I need one more column where the total records which is the sum of bank records and hospital records ie here 150.

    Rerecords Description Count

    Bank Records 50

    Hospital Records 100

    Total Records 150

    Can any one help me with this?

    Thanks

  • It's a little confusing... In your verbal description you're talking about a new colum but your example shows a new row. :ermm:

    If you need a new column, you could use SUM() OVER() and for the new row you might want to look for "ROLLUP" in BOL (BooksOnLine, the SQL Server help system, usually installed together with SQL Server).

    If none of the above will work you could use UNION ALL as a last resort.

    For further explanation (including a coded example based on your scenario) please provide table def for all related tables including sample data in a ready to use format as described in the first link in my signature. Also, please provide your expected result based on the sample data provided together with what you've tried so far.



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Thanks for reply.

    i need to have one more added to my query that i need to use as column in ssrs report.

    basically i need to have one more row with that total count.

    thanks

  • thanks ,

    i will see into it.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply