partyname    state        constituency     candidatename   district    votes

BJP       Maharashtra   Nagpur-East     Nitin Gadkari   Nagpur       1200
AAP       Maharashtra   Nagpur-East     Arvind Kejriwal Nagpur       750
BJP       Maharashtra   Nagpur-West     Vicky           Nagpur       4800
AAP       Maharashtra   Nagpur-West     Lucky           Nagpur       3500
BJP       Maharashtra   Nagpur-North    Rakesh          Nagpur       100
AAP       Maharashtra   Nagpur-North    Ravan          Nagpur       1500


以下是我对上表的预期输出

查询仅从投票组中按参与方名称和选区选择最大vlue,并显示如下输出。

partyname       Count

BJP          2

AAP          1


bcoz bjp来自那格浦尔-东部和那格浦尔西部

所以它显示计数2

而那格浦尔(ag)从那格浦尔(ag)引出-北,那么它仅显示1个计数。

请给我查询...

最佳答案

您可以这样尝试:

select max(votes) from tableName group by constituency


SQL提琴:http://sqlfiddle.com/#!2/ceb017/1

关于php - sql查询从表中选择仅最大值的计数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26294021/

10-11 02:11