4 ms·
But that's equivalent to the following query which doesn't use having, only select select * from (select id, count(*) - 1 as nduplicates from parts
by irishsultan 8y ago
But that's equivalent to the following query which doesn't use having, only select
select * from (select id, count(*) - 1 as nduplicates
from parts where color = 'red'
group by id) _inner
where nduplicates > 0;
Now obviously that doesn't read as easily, but WHERE can filter out the count(*) perfectly.