0

If the table shows like below.

Number     Name
 1          A 
 2          A
 3          B
 4          C
 5          D

So for the example, I want to get the A. Should I use join here?

Shishir Kumar
  • 7,981
  • 3
  • 29
  • 45
SaitoD
  • 25
  • 8

5 Answers5

2

You can use group by simply to get the same.

Select Name from [User] group by Name having COUNT(Name ) > 1
pardeepgarg
  • 82
  • 1
  • 8
1

Try this:

SELECT * FROM (
                SELECT Name,COUNT(*) AS[sum]
                FROM[yourtable]
                GROUP BY Name
                               ) X
WHERE X.[sum] > 1
Jibin Balachandran
  • 3,381
  • 1
  • 24
  • 38
0

Try this code,

SELECT DISTINCT names

It will show unique value of table has more than a value.

Hope this help !

Venkat
  • 316
  • 1
  • 13
0

You can use group by and having to get your required result. You can use also a count to see the how many times same name there SELECT COUNT(name) AS total,name FROM tablename GROUP BY name HAVING COUNT(name) >2

Palash
  • 139
  • 2
  • 7
0

you can use inner join

SELECT a.* FROM tbname AS a
     INNER JOIN (
        SELECT NAME FROM tbname GROUP BY NAME
         HAVING COUNT(NAME)>1
) AS b ON a.name=b.name
Patrick Guimalan
  • 990
  • 9
  • 11