Im trying get an output to use on a different CALL.
output i want is
Row | Col | Data | Seq
<70% | Voters | 5519 | 8
<80% | Voters | 4352 | 8
<90% | Voters | 3251 | 8
100% | Voters | 2511 | 8
the code i have is
SELECT CASE
WHEN (poll_propensity >= 0.70 AND perm_absentee = 'N' AND mail_propensity = 0) THEN '< 70%'
WHEN (poll_propensity >= 0.80 AND perm_absentee = 'N' AND mail_propensity = 0) THEN '< 80%'
WHEN (poll_propensity >= 0.90 AND perm_absentee = 'N' AND mail_propensity = 0) THEN '< 90%'
WHEN (poll_propensity >= 1 AND perm_absentee = 'N' AND mail_propensity = 0) THEN '100%'
END AS Row,
'Voters' AS Col,
COUNT(voter_id) AS Data,
8 AS Seq
FROM ( SELECT p.voter_id, p.perm_absentee, vp.poll_propensity, vp.mail_propensity
FROM VoterProfile p
INNER JOIN DistrictPrecinct d ON d.precinct_id=p.precinct_code
INNER JOIN VoterPropensity vp ON p.voter_id=vp.voter_id
WHERE d.district_id= 3 AND vp.election_type= 'T' ) as derived
GROUP BY Row
but all im getting output is like
Row | Col | Data | Seq
<70% | Voters | 5519 | 8
only one comes through if anyone can help that would be great
Simply change the orders of the WHEN statements since 1 > .7 the 1’s are being lumped in with the .7 you need to start with .1 and then go down to the .7.
Alternatively, you could change the operation from >= to < and leave the order the same; but I’m not sure that’s going to give you the same subset your looking for.