您可以根据您需要的值获得计数(distcint id)。例如。对于这两个值:
select count(distinct id), highest_item, highest_level
from (
SELECT id,
MAX(item) AS highest_item,
MAX(level) AS highest_item
FROM data
GROUP BY 1
) t
group by highest_item, highest_level
order by count(distinct id) desc
或highest_item
select count(distinct id), highest_item
from (
SELECT id
MAX(item) AS highest_item,
MAX(level) AS highest_level
FROM data
GROUP BY 1
) t
group by highest_item
order by count(distinct id) desc
的
为HIGHEST_LEVEL
select count(distinct id), highest_level
from (
SELECT id,
MAX(item) AS highest_item,
MAX(level) AS highest_level
FROM data
GROUP BY 1
) t
group by highest_level
order by count(distinct id) desc
利用你的第一个建议,组我得到一个简单计数的结果表,其中不是我所需要的,我需要一个包含关卡#,项目ID和有多少不同用户与同一项目处于同一级别的表。你能否在你的查询中解释“t”字符的用途? – nyvokub
添加了关卡...... t是()t ..子查询的表名,但是用户与问题的关系如何(我假设你是meadn是这个id的数目)。我在查询中没有看到任何用户列。 – scaisEdge