GROUP BY WITH HAVING ( DISTINCT ) : PHP , MYSQL
问题 id | mid | pid | owgh | nwgh | 1 3 12 1.5 0.6 2 3 12 1.5 0.3 3 3 14 0.6 0.4 4 3 15 1.2 1.1 5 4 16 1.5 1.0 6 4 17 2.4 1.2 7 3 19 3.0 1.4 From Above i want total count of mid AND SUM of nwgh with its resp. id ex: mid=3 or mid=4 but with DISTINCT pid but please note sum of nwgh should not be DISTINCT Hence my result will be as below : mid | countmid | totalnwgh 3 4 (DISTINCT value) 3.8 (no DISTINCT it take both value of pid =12) 4 2 2.2 in above result mid = 3 have count 4 beause pid = 12 is