COUNT(*) and COUNT(column) give me different numbers
Asked by Leilani Kahale · 472 views · 3 replies
For my budgeting app I want the number of expenses per category, including categories with none. This shows 1 for empty categories instead of 0:
SELECT c.name, COUNT(*) AS expenses
FROM categories c
LEFT JOIN expenses e ON e.category_id = c.id
GROUP BY c.name;
Someone said to use COUNT(e.id) and that does give 0. But why are they different at all?