Subject | RE: [firebird-support] SQL conundrum - count disregarding date parameters |
---|---|
Author | Clay Shannon |
Post date | 2005-07-26T18:05:48Z |
<< Anyway, you could speed up this query if you use Firebird 1.5 by using
the CASE expression
SELECT>
a.gender,
SUM(CASE WHEN a.actioncode = 1 THEN 1 ELSE 0 END) as hired,
SUM(CASE WHEN a.actioncode = 2 THEN 1 ELSE 0 END) as
interviewed_declinedoffer,
SUM(CASE WHEN a.actioncode = 3 THEN 1 ELSE 0 END) as interviewed_nooffer,
SUM(CASE WHEN a.actioncode = 4 THEN 1 ELSE 0 END) as not_interviewed,
....
FROM
hr_applicants a
WHERE
a.actiondate between ('6/26/2005') and ('7/26/2005')
GROUP BY
a.gender
Regards,
Arno Brinkman>>
Nice Brinkmanship--it works like a cha[mp,rm]!
Give me a shout the next time you're in Oconomowoc, I'll buy you a beer!
Clay Shannon,
Dimension 4 Software
the CASE expression
SELECT>
a.gender,
SUM(CASE WHEN a.actioncode = 1 THEN 1 ELSE 0 END) as hired,
SUM(CASE WHEN a.actioncode = 2 THEN 1 ELSE 0 END) as
interviewed_declinedoffer,
SUM(CASE WHEN a.actioncode = 3 THEN 1 ELSE 0 END) as interviewed_nooffer,
SUM(CASE WHEN a.actioncode = 4 THEN 1 ELSE 0 END) as not_interviewed,
....
FROM
hr_applicants a
WHERE
a.actiondate between ('6/26/2005') and ('7/26/2005')
GROUP BY
a.gender
Regards,
Arno Brinkman>>
Nice Brinkmanship--it works like a cha[mp,rm]!
Give me a shout the next time you're in Oconomowoc, I'll buy you a beer!
Clay Shannon,
Dimension 4 Software