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.
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
This is sql server 2005 so I can’t do a group of a set. I also have tried to get a union of two queries to work and it keeps giving me a syntax error.
This might be what you’re after:
See here for some more detailed examples, including how to show a more meaningful summary line
https://web.archive.org/web/20211020145951/https://www.4guysfromrolla.com/articles/073003-1.aspx