select id, score, (select count(*) from 表A where score = B.score) as 数量 from 表A as B where id = (select min(id) from 表A where score = B.score) order by id desc
1、score值相同的记录只列出一次 SELECT DISTINCT(SCORE) FROM A 2、统计score值相同的数量 3、查询结果按id降序排列。 SELECT SUM(SCORE) FROM A WHERE SCORE IN(SELECT SCORE FROM A GROUP BY SCORE HAVING COUNT(SCORE)>1) ORDER BY id DESC
select id,name, (select top 1 distinct score from table t where table.id=t.id) as score,(select count(score) from table t where table.score=t.score group by score) as数量 from table order by id desc
select max(id) as id,score,count(*) as 数量 from table group by score order by id desc
from 表A as B where id = (select min(id) from 表A where score = B.score)
order by id desc
SELECT DISTINCT(SCORE) FROM A 2、统计score值相同的数量
3、查询结果按id降序排列。
SELECT SUM(SCORE)
FROM A
WHERE SCORE IN(SELECT SCORE FROM A GROUP BY SCORE HAVING COUNT(SCORE)>1)
ORDER BY id DESC
from table
order by id desc