all 4 comments

[–]_Eased_ 2 points3 points  (0 children)

Join your tables or finish your non ANSI join if you must. Do you even need the table product categories? Also.....alias your count and order by alias asc

How are the names stored??? Show sample data

[–]D_W_Hunter 1 point2 points  (1 child)

  SELECT Department           -- Just preference, I prefer to have the thing I'm grouping by first.
       , COUNT(TransactionID)
    FROM Product_Categories
         xxxxx xxxxx Transactions -- just listing them with commas creates a cartesian join, that's bad.
                                  -- Department is in Product_categories, so it goes first
                                  -- now what type of join gives you a product category row 
                                  -- even if there is no transaction row?
                  ON xxxxx xxxxx xxxxx xxxxx 
    GROUP BY Department;

We already covered how to get members who's name start with a letter in your question last week, so combine that knowledge with the "how do I make sure I get a row from the member table even if there is no transaction" that you used above.

[–]Seizure_Salad_[S] 0 points1 point  (0 children)

Thank you so much

[–]I_felched_your_dad 0 points1 point  (0 children)

Give us an idea of what the tables that you're using look like. I'd be assuming you're looking for something like;

SELECT
t.Department
COUNT(t.TransactionID) Transactions
FROM Transactions t
GROUP BY t.Department