Skip to main content
2 of 2
added 1 character in body
user avatar
user avatar

You can use conditional aggregation with an outer join

select count(*) filter (where at.asset_id is not null) with_unique_id, 
       count(*) filter (where at.asset_id is null) as without_unique_id
from assets a
  left join associated_table at on at.asset_id = a.asset_id;
user1822