I have a table like this:
shopID supplier supply_count
1 a 12
1 b 10
1 c 8
1 d 7
2 b 12
2 f 12
2 e 10
3 b 5
3 a 2
4 f 15
4 c 11
I used the not in function like this:
where supply_count NOT IN (select max(supply_count) from supply)
However, only the first row show the 2nd highest value in the result, the other rows still showing the highest count:
shopID supply_count
1 10
2 12
3 5
4 15
My expected result is to find the 2nd highest supply count for each shop like this:
shopID supply_count
1 10
2 12
3 2
4 11
So, anyone have some suggestions? thanks!