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 |
|
hmrnmky
Starting Member
2 Posts |
Posted - 2011-03-02 : 14:14:16
|
| I have query that finds duplicate placer numbers however I need to add to the query to only show those records where the patientid is not the same for both records.select placerordernum, fillerordernum, patientid, reportdatetime, reportidfrom reportinfowhere placerordernum in (select [placerordernum] from [reportinfo] as tmp group by [placerordernum] having count (*) > 1)I've tried different configurations of NOT Distinct without any success, any ideas? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-03-02 : 14:19:48
|
| select placerordernum, fillerordernum, patientid, reportdatetime, reportidfrom reportinfowhere placerordernum in (select [placerordernum] from [reportinfo] as tmp group by [placerordernum] having count (distinct patientid) > 1) |
 |
|
|
hmrnmky
Starting Member
2 Posts |
Posted - 2011-03-02 : 15:33:39
|
| Thank you very much, it works like a charm. |
 |
|
|
|
|
|