help with sql query
everything looks right to me, but i'm not getting the results I want. I want to have a list of all categories from table 1 and a count number based on table 2. Right now I'm only getting returned the categories that are not null.
i.e. i want
category 1 - 50
category 2 - 50
category 3 - 0
category 4 - 50
etc.
right now I'm getting:
category 1 - 50
category 2 - 50
category 4 - 50
etc.
"SELECT table1.categoryName, ISNULL(COUNT(table2.id), 0) AS TotalCategories FROM table1 LEFT OUTER JOIN table2 ON table1.categoryName = table2.category WHERE (table2.expireDate >= GETDATE()) GROUP BY table1.categoryName ORDER BY TotalCategories DESC"
I'd settle for just that answer, but if you're feeling extra helpful today:
once the query is doing what i need... i then would like to put this info into a string of dynamic text like so
50,50,0,50
(if you haven't guessed, i'm building a pie chart using google charts api).
Thank you in advance for an answer to my oversight.
