| Author |
Topic |
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-10-03 : 08:59:43
|
| I am not sure how to go about asking this. I have a database that imported multiple products under a tin. I was wondering how I can go about find all of them. What I am thinking is....Give me all taxid (pcsa_tax1)that have duplicate products "DGH" (pcsp_prd). Not sure if this is enough information for you.TaxID 2459872548BROOKLYN PEDIATRIC ASSOCIATES DEVON DGH EFF: 06/01/2003 TRM: PHYFEE BCD DEVON DGH EFF: 05/15/2003 TRM: PHYFEE BCD |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-10-03 : 09:30:15
|
| This is what I have so far.select * from VW_Double_Pricingwhere PCSA_tax1 in (Select DistinctPCSA_tax1From VW_Double_Pricingwhere pcsp_prd = 'DGH'group by PCSA_tax1HAVING COUNT (pcsp_prd) > 1)order by pcs_lname |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-03 : 09:40:57
|
quote: Originally posted by werhardt I am not sure how to go about asking this. I have a database that imported multiple products under a tin. I was wondering how I can go about find all of them. What I am thinking is....Give me all taxid (pcsa_tax1)that have duplicate products "DGH" (pcsp_prd). Not sure if this is enough information for you.TaxID 2459872548BROOKLYN PEDIATRIC ASSOCIATES DEVON DGH EFF: 06/01/2003 TRM: PHYFEE BCD DEVON DGH EFF: 05/15/2003 TRM: PHYFEE BCD
SELECT taxidFROM YourTable tJOIN (SELECT pcsp_prdFROM YourTableGROUP BY pcsp_prdHAVING COUNT(*) >1)tmpON tmp.pcsp_prd=t.pcsp_prd |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-10-03 : 09:49:24
|
| Ok this is working below, but it is also brining over ones that have mulitple addresses. is there a way that I can say something like PCSA_ADDR1<>PCSA_ADDR1? select * from VW_Double_Pricingwhere PCSA_tax1 in (Select DistinctPCSA_tax1From VW_Double_Pricingwhere pcsp_prd = 'DGH' --and--PCSA_ADDR1 <> p.PCSA_ADDR1group by PCSA_tax1HAVING COUNT (pcsp_prd) > 1)order by pcs_lname |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-03 : 09:52:45
|
quote: Originally posted by werhardt Ok this is working below, but it is also brining over ones that have mulitple addresses. is there a way that I can say something like PCSA_ADDR1<>PCSA_ADDR1? select * from VW_Double_Pricingwhere PCSA_tax1 in (Select DistinctPCSA_tax1From VW_Double_Pricingwhere pcsp_prd = 'DGH' --and--PCSA_ADDR1 <> p.PCSA_ADDR1group by PCSA_tax1HAVING COUNT (pcsp_prd) > 1)order by pcs_lname
you mean br4ing only ones having duplicate pcsp_prd,address combination? then use belowSELECT taxidFROM YourTable tJOIN (SELECT pcsp_prd,addressFROM YourTableGROUP BY pcsp_prd,addressHAVING COUNT(*) >1)tmpON tmp.pcsp_prd=t.pcsp_prdAND tmp.address=t.address |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-10-03 : 11:45:16
|
| This is starting to look good, but it is still not pulling like i want it to. Maybe it can't be done.It is pulling both of these for this doctor, maybe I shouldn't use the taxid. Maybe I should use the PCS number that goes to the doctor. I only want it to pull the one in in read because they have the product twice under that doctor.ALFRED SWYER 1176 5TH AVENUE, BOX 1235TAX-009010020 NEW YORK, NY 10029 * DAMTS DGH EFF: 11/05/2002 TRM: PHYFEE MT. SINAI RADIOLOGY ASSOCIATES 1176 FIFTH AVE. TAX-136171197 NEW YORK, NY 10029-6503 * DAMTS DGH EFF: 10/02/2006 TRM: PHYFEE * GHINA PPO EFF: 07/01/1996 TRM: GHINAL * GHINA PPO EFF: 11/06/2003 TRM: GHINAL |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-03 : 11:53:19
|
quote: Originally posted by werhardt This is starting to look good, but it is still not pulling like i want it to. Maybe it can't be done.It is pulling both of these for this doctor, maybe I shouldn't use the taxid. Maybe I should use the PCS number that goes to the doctor. I only want it to pull the one in in read because they have the product twice under that doctor.ALFRED SWYER 1176 5TH AVENUE, BOX 1235TAX-009010020 NEW YORK, NY 10029 * DAMTS DGH EFF: 11/05/2002 TRM: PHYFEE MT. SINAI RADIOLOGY ASSOCIATES 1176 FIFTH AVE. TAX-136171197 NEW YORK, NY 10029-6503 * DAMTS DGH EFF: 10/02/2006 TRM: PHYFEE * GHINA PPO EFF: 07/01/1996 TRM: GHINAL * GHINA PPO EFF: 11/06/2003 TRM: GHINAL
ok. so now what you should do is to give some sample data from your table and then give your expected output out of them. |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-10-07 : 10:13:52
|
| Ok, I am still having problems with pulling dups. You said something about giving you some data to test it on. How would I do that? Would I just copy it into this forum?I think I need to change the way the query is too. It is pulling the DGH, but it is pulling if for every provider. I want to limit it to say If there is a Address (pcsa_addr1) that has (pcsp_prd) "DGH" under it more than once, then I want to see them in my results.SELECT taxidFROM YourTable tJOIN (SELECT pcsp_prdFROM YourTableGROUP BY pcsp_prdHAVING COUNT(*) >1)tmpON tmp.pcsp_prd=t.pcsp_prdDiane Weaver M.D.Network ProductDevon DGHDevon DGH |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-10-07 : 10:20:13
|
| You can post a simple script.create temp table (...)insert some example datathen explain expected output in relation to example data.GreetingsWebfredPlanning replaces chance by mistake |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-07 : 10:20:48
|
| provide some sample data along with your table column info and show us what your output should be.http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-10-07 : 10:22:32
|
| Oh, sorry visakh.I don't wanted to disturb.Planning replaces chance by mistake |
 |
|
|
|