Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Eliminating dups using multiple tables
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01128331
Message ID:
01128359
Views:
23
>You could do this in one select (I don't say it will be fasterm but you could try)
>
>select cPatients_pk, tEntered_Date, tLast_Updated_Date, Patients.dDOB, ;
>	cSSN, cSex_Code, cntDups,;
>        Names.cf_Name, Names.cl_Name, Names.cM_Initial, ;
>        Address.cStreet1, Address.cCity, ;
>        nvl(cAREA_CODE,space(3)) as cArea_Code, ;
>        nvl(cEXCHANGE,space(3)) as cExchange, ;
>        nvl(cLAST_FOUR, space(4)) as cLast_Four,;
>FROM (SELECT COUNT(*) AS cntDupsm, MAX(cPatients_pk) AS cPatients_pk, MAX(tEntered_Date) AS tEntered_Date,
>             MAX(tLast_Updated_Date) AS tLast_Updated_Date, dDOB, cSSN, MAX(cSex_Code) AS cSex_Code;
>      FROM Patients;
>      GROUP BY cSSN,dDOB;
>      WHERE NOT EMPTY(cSSn) AND NOT EMPTY(dDOB);
>      HAVING cntDupsm > 1) cr;
>inner join Names   on cr.cPatients_pk = Names.cPointer_fk ;
>inner join Address on cr.cPatients_pk = Address.cPointer_fk ;
>left  join Phones  on cr.cPatients_pk = Phones.cPointer_fk ;
>order by dDOB, cSSN, cSEX_Code,Names.cl_Name, Names.cf_Name;
>into cursor curDupPatients readwrite
>
>
I think you're right, but in this particular case one or two selects doesn't really matter as long as it works. I'll post my full code in a minute, you can tell me, if I'm doing something wrong in your opinion.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform