Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
i know how to find duplicate values using count() but my question is how can i find duplicate values starting with some letter like'A' or 'K'

i have a table tblmytable like this

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

gives me this result

rollnumber countof

A100156 2
P102555 2

i want to find duplicate roll numbers starting with 'A'

like this how can i modify the query


What I have tried:

select rollnumber,count(rollnumber) AS COUNTOF from tblmytable group by rollnumber having count(rollnumber)>1 order by rollnumber
Posted
Updated 21-Feb-17 1:11am

1 solution

select rollnumber,count(rollnumber) AS COUNTOF from tblmytable group by rollnumber having count(rollnumber)>1 order by rollnumber WHERE rollnumber LIKE 'A%'

You can read more here: SQL LIKE Operator[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900