我知道如何使用count()查找重复值 但我的问题是如何找到重复的值,从一些字母开始,如' A'或者' K'
我有一个像这样的表格
id rollnumber city fess
1 A100156 Ajamer 450
2 P102555 Pune 450
3 A100156 Ajamer 450
4 P102555 Pune 450
查询
select rollnumber,count(rollnumber) AS COUNTOF
from tblmytable
group by rollnumber
having count(rollnumber) > 1
order by rollnumber
给了我这个结果
rollnumber countof
A100156 2
P102555 2
我想找到以' A'
开头的重复卷号像这样如何修改查询
答案 0 :(得分:2)
只需在
上加上WHERE子句select rollnumber,count(rollnumber) AS COUNTOF
from tblmytable
where rollnumber like 'A%'
group by rollnumber
having count(rollnumber)>1 order by rollnumber