Websites:
website_Id | website_name |
---|---|
1 | website_a |
2 | website_b |
3 | website_c |
4 | website_d |
5 | website_e |
Fixtures:
fixture_Id | website_id | fixture_details |
---|---|---|
1 | 1 | a vs b |
2 | 1 | c vs d |
3 | 2 | e vs f |
4 | 2 | g vs h |
5 | 4 | i vs j |
Expected Output:
website_Id | website_name | TotalRows |
---|---|---|
1 | website_a | 2 |
2 | website_b | 2 |
3 | website_c | 0 |
4 | website_d | 1 |
5 | website_e | 0 |
I would like to get 0 when there are no entries in the fixture table.
Select fx.website_id, ws.website_name, Count (*) as TotalRows
FROM fixtures fx
LEFT JOIN websites ws on ws.website_id = fx.website_id
WHERE date_of_entry = '16-01-2023'
GROUP BY
fx.website_id, ws.website_name
But this does not return 0 when there are no entries.
How can I change my SQL to reflect this?