Comparing COUNT values within a query?
Posted
by outsyncof
on Stack Overflow
See other posts from Stack Overflow
or by outsyncof
Published on 2010-03-14T05:19:42Z
Indexed on
2010/03/14
5:25 UTC
Read the original article
Hit count: 308
I have the following tables in a relation:
person(ssn,sex) employment(ssn,workweeksperyear)
assume ssn is a key.
My assignment was to do this:
Given as input the number of weeks per year a person has worked, determine whether there are more males than females who work more weeks than the input value.
SELECT COUNT(sex) AS NumMales
FROM person
WHERE sex = 'Male' AND ssn IN (SELECT ssn
FROM employment
WHERE workweeksperyear > 48);
The above query gets me the number of males for an input value and I could do the same for number of females but how do I compare the 2 results?
Any help will be greatly appreciated!
© Stack Overflow or respective owner