Subject | Re: [firebird-support] This SQL conundrum is breaking my head |
---|---|
Author | Arno Brinkman |
Post date | 2005-04-22T20:19:22Z |
Hi,
If you've no problems with a row per action (what i prefer):
SELECT
a.gender,
a.ActionTaken,
Count(*)
FROM
Applicants a
GROUP BY
a.gender,
a.ActionTaken
in FB1.5 if you want the results in columns:
SELECT
a.gender,
SUM(CASE a.ActionTaken = 'Hired' THEN 1 ELSE 0 END) AS Hired,
SUM(CASE a.ActionTaken = 'Not Interviewed' THEN 1 ELSE 0 END) AS "Not Interviewed",
SUM(CASE a.ActionTaken = 'Interviewed-job declined' THEN 1 ELSE 0 END) AS "Interviewed-job
declined",
SUM(CASE a.ActionTaken = 'Did not meet qualifications' THEN 1 ELSE 0 END) AS "Did not meet
qualifications"
FROM
Applicants a
GROUP BY
a.gender
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info
>>From a table that stores such things about a job applicant as gender, race,<snip>
> disability, veteran status, etc. and which table also holds an "Action
> taken" column (which can be:
If you've no problems with a row per action (what i prefer):
SELECT
a.gender,
a.ActionTaken,
Count(*)
FROM
Applicants a
GROUP BY
a.gender,
a.ActionTaken
in FB1.5 if you want the results in columns:
SELECT
a.gender,
SUM(CASE a.ActionTaken = 'Hired' THEN 1 ELSE 0 END) AS Hired,
SUM(CASE a.ActionTaken = 'Not Interviewed' THEN 1 ELSE 0 END) AS "Not Interviewed",
SUM(CASE a.ActionTaken = 'Interviewed-job declined' THEN 1 ELSE 0 END) AS "Interviewed-job
declined",
SUM(CASE a.ActionTaken = 'Did not meet qualifications' THEN 1 ELSE 0 END) AS "Did not meet
qualifications"
FROM
Applicants a
GROUP BY
a.gender
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database (based on IB-OE) with many SQL-99 features :
http://www.firebirdsql.org
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/
Support list for Interbase and Firebird users :
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep :
news://newsgroups.firebirdsql.info