Select Distinct id as personID, count(tid) as Sales
From salesTable
Group by personID;
当前结果是:(我只需要显示最高销售额。)
personID | Sales
_____________________
1000 | 2
1020 | 1
1040 | 2
1060 | 1
1080 | 2
1140 | 1
1160 | 1
_________________
salesTable 如下所示:
id | tid
_________
1000|201
1020|202
1040|203
1000|204
1060|205
1080|206
1040|207
1080|208
1140|209
1160|210
我想要的结果应该是这样的:
personID | Sales
_____________________
1000 | 2
1040 | 2
1080 | 2
_________________