Subject | Re: [firebird-support] This SQL conundrum is breaking my head |
---|---|
Author | Thomas Steinmaurer |
Post date | 2005-04-22T19:08:36Z |
>>From a table that stores such things about a job applicant as gender, race,Something like that?
> disability, veteran status, etc. and which table also holds an "Action
> taken" column (which can be:
>
>
>
> Hired
>
> Not Interviewed
>
> Interviewed-job declined
>
> Did not meet qualifications
>
> Etc.
>
>
>
> I need to be able to see which actions were taken by gender, by race, etc.
>
>
>
> The only "start" that I can come up with is something like:
>
>
>
> Select gender, Count(ActionTaken)
>
>>From Applicants
>
> Where Action = Hired
>
> Group by Gender
>
>
>
> But I need the results for every action taken, not just "Hired" - I need
> results like:
>
>
>
> Gender Hired Not Interviewed Did Not
> Meet Quals
>
> Male 2 3
> 2
>
> Female 3 2
> 1
select distinct
a.gender,
(select count(*) from APPLICANTS where actiontaken = 'Hired' and
gender=a.gender) as hired,
(select count(*) from APPLICANTS where actiontaken = 'Not
Interviewed' and gender=a.gender) as not_interviewed,
(select count(*) from APPLICANTS where actiontaken = 'Did not meet
qualifications' and gender=a.gender) as did_not_meet_quals
from
applicants a
--
HTH,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2 (NEW!)
Upscene Productions
http://www.upscene.com