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?
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') 

Open in new window

LVL 1
WeTiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
there is probably no duplicate in the result, you are assuming this wrongly
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

select medlemsnr, count(*) 
from separate_table
group by medlemsnr 
having count(*) > 1

Open in new window

0
WeTiAuthor Commented:
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...
0
WeTiAuthor Commented:
Sorry, I forgot to edit the search criteria. now its correct.
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

WeTiAuthor Commented:
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.
0
Geert GOracle dbaCommented:
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'
0
WeTiAuthor Commented:
Yes that is my question, I want sql to show those duplicate...
0
Geert GOracle dbaCommented:
you can't with an in clause

insert those numbers into a new separate table
and then join with that separate table

create table #crit (membershipID int);

insert into #crit (membershipId) values (392102);
insert into #crit (membershipId) values (392371);
... etc 

SELECT m.[Membership]
      ,m.[Membershipid] ,m.[firstnamn]
      ,m.[lastnamn]
  FROM [company].[db].[Member] m, #crit c 
  Where m.membershipID = c.membershipID;

Open in new window


that'll give you the duplicates
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WeTiAuthor Commented:
Great solution! Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.