|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
heyas,
i wanna know how can i select only entries with at least 2 rows? What i mean is that i want to make a select * from table1 where columnA = 'Something' order by columnB but addicionally i want it to return only register that happen at least 2 times for columnB thanks in advance! |
|
#2
|
||||
|
||||
|
register?
could you please give some example rows and the result you expect? |
|
#3
|
|||
|
|||
|
Try this, it should work
I think there is an easier way to do this, but this is what comes to my mind right now...
SELECT table1.* FROM table1 INNER JOIN (SELECT Column1, COUNT(Column1) FROM table1 WHERE (Column1 = 'IYAD') GROUP BY Column1 HAVING (COUNT(Column1) > 1)) AS tempTable ON table.Column1 = tempTable.Column1 ORDER BY table.Column2 You are basically joining on the same table, thats why you are naming the second result set AS tempTable |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > How can i select only entries with at least 2 rows? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|