我试图让输出在不同的 CALL 上使用。我想要的输出是
Row | Col | Data | Seq
<70% | Voters | 5519 | 8
<80% | Voters | 4352 | 8
<90% | Voters | 3251 | 8
100% | Voters | 2511 | 8
我的代码是
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
但我得到的所有输出就像
Row | Col | Data | Seq
<70% | Voters | 5519 | 8
如果有人可以提供帮助,那就只有一个通过,那就太好了