Results 1 to 4 of 4

Thread: Count of a Sum

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    Unanswered: Count of a Sum

    Hey,

    I'm trying to do a sum of a count. I'm running the below query. I want a sum of BrowserCount however I want to return the datatable which is returned by this query. Is that possible should I be using a return value? Or is there another way? I realize there's been a decent amount of posts on this but I couldn't get this to run using them. Thanks in advanced for your help!

    Select UA.Browser_ID, B.Browser_Name_NM, count(B.Browser_Name_NM) as BrowserCount From llc.User_Agent_TB as UA
    Left Join llc.Browser_TB as B on UA.Browser_ID = B.Browser_ID
    Group by B.Browser_Name_NM, UA.Browser_ID
    Order by BrowserCount DESC

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Hi,

    Try:

    Code:
    Group by Grouping Sets((B.Browser_Name_NM, UA.Browser_ID), ())
    Hope this helps.

  3. #3
    Join Date
    Nov 2012
    Posts
    2
    Sadly, I'm using SQL server 2005 and google said that I can only use that in 2008+?

    Thank you for your help though. If you have any more ideas, let me know.

    Thanks.

  4. #4
    Join Date
    Apr 2012
    Posts
    213
    Try:

    Code:
    Group by B.Browser_Name_NM, UA.Browser_ID with rollup
    Hope it's useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •