在我的表中有 2 列。 名称
和标记
。像这样。
Name Marks
---------- -----------
AAA 50
BBB 48
CCC 54
AAA 52
DDD 55
BBB 60
AAA 66
我需要从表格中检索如下内容
Name No.of.attempts Max Mark
------- ---------------- ------------
AAA 3 66
BBB 2 60
CCC 1 54
DDD 1 55
最佳答案
你应该这样做:
select name,count(name) as no_of_attempts,max(marks)
from table_name
group by name
fddle demo here
关于sql - 在 sql 中选择不同名称和计数名称的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20346655/