SELECT s_id,f_name,COUNT(f_name) as 重复次数
from fruit
GROUP BY s_id,f_name
HAVING COUNT(f_name)>=2
ORDER BY s_id,f_name
对s_id和f_name先后进行分组后,对第二次分组的f_name计数>=2就是重复次数
SELECT s_id,f_name,COUNT(f_name) as 重复次数
from fruit
GROUP BY s_id,f_name
HAVING COUNT(f_name)>=2
ORDER BY s_id,f_name
对s_id和f_name先后进行分组后,对第二次分组的f_name计数>=2就是重复次数