I would like to know if there is an opposite of \"select distinct\" in sql ,so that i can use to get values from a table of only which has repeated multiple times.
Thank
You need a group by
with a having
clause, something like:
select person, count(friends)
from people
group by person
having count(friends) > 1
This would give you a list of all people and their friend count, except for those poor sad soles who have been befriended by only their mothers or, worse yet, not even their mothers :-)
You have to use having
instead of where
in this case, since the former filters after grouping while the latter filters before, and you don't have the information of aggregate functions like count()
until after grouping has taken place.