Dear friend of Stackoverflowers,
How can I select 2 different counts from one table for scenarios:
x=a and x=b
in particular, (WHEN type = subdomain) AND (WHEN subtype = subdomain)?
to add them together to create a "totalcount"?
My attempt (for your reference):
SELECT description, type, count(1), subtype, count(2) FROM mapping, (dotcom WHERE type = subdomain) AS typecount, (dotcom WHERE subtype = subdomain) AS subtypecount GROUP BY description, type, subtype HAVING count(1)>1 AND count(2)>1 ORDER BY count(*) DESC LIMIT 10
Second attempt:
SELECT description FROM mapping, SUM(WHEN subdomain = type OR subdomain = subtype) AS count(1) GROUP BY description, type, subtype HAVING count(1)>1 ORDER BY count(*) DESC LIMIT 10
source share