WeTi
asked on
Show SQL duplicated result
Dear expert
I got question about duplicating the query, now when I select query like code below the sql automaticly remove the duplicated result, the deal here is I want SQL to show duplicated result... how to do that?
I got question about duplicating the query, now when I select query like code below the sql automaticly remove the duplicated result, the deal here is I want SQL to show duplicated result... how to do that?
SELECT [Membership]
,[Membershipid] ,[firstnamn]
,[lastnamn]
FROM [company].[db].[Member]
Where membershipID in ('392102','392371', '394240', '394240', '394910', '394910', '395173'
, '395173', '395173', '395189', '395189', '395189', '395782','396232', '396232', '396232', '396509', '396509', '396509'
,'398145', '398166' ,'399037' , '399230', '401361', '401361'
,'401361', '401361', '411750', '411856' , '412141' , '412141'
,'414297' , '414297','414770','414770','415043','415043','415288','416131','416251','416251','416251','416917','417459',
'417906','417906','417906','418765','418905','418905','419177','419177','419228','419228','419348','419417','419887',
'419947','419991','420063','420063','420108','420319','420319','420319','420763','420963','421685','421685','421685',
'421882','421882','422296','422296','422508','422508','422856','422856','423003','423180','423255','424130','424130',
'424148','424148','424820','425036','425036','425495','425495','425495','425495','425495','425495','425495','425495',
'425495','425495','425495','425495','425495','425495','425495','425495','425495','425495','425495','425495','425495',
'425495','425861','426021','426082','426083','426089','449926','449926')
ASKER
Compare with a excel, in excel there are duplicated lines with other info, I just need to export this query to copy the result in it, I thought... However the query auto remove all the duplicated ids... I cannot mark all and copy...
ASKER
Sorry, I forgot to edit the search criteria. now its correct.
ASKER
You said:
if you have duplicates in your search criteria, then those are ignored
you have duplicates in your search criteria
Yes I need sql to show those duplicates in my search criteria... not ignore them.
if you have duplicates in your search criteria, then those are ignored
you have duplicates in your search criteria
Yes I need sql to show those duplicates in my search criteria... not ignore them.
then insert them into a separate table
with a join you can have duplicates
how do you mean now it is correct ?
your search criteria has still got duplicates
that's 3 of these :
'395173', '395173', '395173'
with a join you can have duplicates
how do you mean now it is correct ?
your search criteria has still got duplicates
that's 3 of these :
'395173', '395173', '395173'
ASKER
Yes that is my question, I want sql to show those duplicate...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great solution! Thanks.
if a row matches a criteria, it matches,
it won't return the same row more if it matches the criteria multiple times
if you have duplicates in your data, then they will show
if you have duplicates in your search criteria, then those are ignored
you have duplicates in your search criteria
how did you build that search criteria ?
you need to look there for duplicates
insert your search criteria into a separate table
and then check that separate table with a group by
Open in new window