I have 3 tables, with Table B & C referencing Table A via Foreign Key. I want to write a query in PostgreSQL to get all ids from A and also their total occurrences from
Another option:
SELECT a.id, (SELECT COUNT(*) FROM b WHERE b.a_id = a.id) + (SELECT COUNT(*) FROM c WHERE c.a_id = a.id) FROM a