下面是我显示分区的查询,但我需要选择其分区= nagpur
的所有数据我的意思是,我想在我的查询中放置条件。请建议我如何实现以下查询中的条件。
SELECT RES.PARTYNAME, RES.DISTRICT, COUNT(RES.CONSTITUENCY) AS VOTESCOUNT
FROM voter_count RES
JOIN
(SELECT CONSTITUENCY, MAX(VOTES) AS VOTES
FROM voter_count
GROUP BY CONSTITUENCY) MAXS
USING (VOTES, CONSTITUENCY)
GROUP BY PARTYNAME,DISTRICT
答案 0 :(得分:0)
尝试以下查询
SELECT RES.PARTYNAME, RES.DISTRICT, COUNT( RES.CONSTITUENCY ) AS VOTESCOUNT
FROM voter_count RES
JOIN
(SELECT CONSTITUENCY, MAX(VOTES) AS VOTES
FROM voter_count
GROUP BY CONSTITUENCY) MAXS
USING (VOTES, CONSTITUENCY)
WHERE RES.DISTRICT = 'nagpur'
GROUP BY PARTYNAME, DISTRICT