Answer the question
In order to leave comments, you need to log in
How to make an ms SQL query so that it counts the same values in a column and records the number of matches?
For example, there is a table like this:
id.........User
1........Who-ho
2..........Who
3.......Who -ho
4........Anybdy
5.........Who You
need to write a query that will show how many matches the "User" column has, by type:
id....... ..user..........matches
1........Who-ho ........2
2..........Who ... ..........2
3.......Who-ho.........2
4........Anybdy........ ...1
5.........Who.............2
Answer the question
In order to leave comments, you need to log in
SELECT ID, User, (SELECT COUNT(*) FROM a AS b WHERE b.User = a.User) AS Matches FROM a
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question