Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Tamaradenise
Starting Member
7 Posts |
Posted - 2014-12-24 : 23:13:23
|
Table PATIENT has columns PATIENT_ID, FNAME, and LNAME. Write a query that will identify duplicate PATIENT_IDs in the table PATIENT. The query should return all three columns and include all rows where the PATIENT_ID shows up more than once in the table.Tamara |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-12-25 : 19:08:39
|
http://www.sqlteam.com/article/deleting-duplicate-records KH[spoiler]Time is always against us[/spoiler] |
|
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-12-26 : 07:52:54
|
[code]CREATE TABLE PATIENT (PATIENT_ID int,FNAME varchar(1024),LNAME varchar(1024))INSERT INTO PATIENT SELECT 1,'Jhon','kel' UNION ALLSELECT 1 ,'Rute','Obriean' UNION ALLSELECT 3 ,'james','steve' UNION ALLSELECT 3 ,'Peter','Mac' UNION ALLSELECT 3 ,'jack','rans' UNION ALLSELECT 5 ,'rober','tom' SELECT * FROM ( SELECT *,COUNT(*)OVER(PARTITION BY (PATIENT_ID )) Cn FROM PATIENT )aWHERE a.Cn > 1 [/code]---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
Tamaradenise
Starting Member
7 Posts |
Posted - 2014-12-26 : 16:20:17
|
Thank yall for the helpTamara |
|
|
|
|
|
|
|