Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting sequential sick persons
Message
From
18/09/2007 10:07:02
 
 
To
18/09/2007 09:46:01
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brazil
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01255094
Message ID:
01255123
Views:
14
Hi

I got the following message:
SQL: Error correlating fields (Error 1801)

>Hi Chaim,
>
>>Hi
>>Program for laboratory
>>
>>I have a table with two fields: personid and disease.
>>This table contain only the person that diagnosed sick for one disease or more and the diagnosed diseases (Person can be sick for more than 1 disease).
>>
>>I want to find persons that sick for same disease of the next/previous personid (if they tested togother maybe the tubes mixed).
>>In the following examle I will get the persons 931694/5 sicks for same disease.
>>
>>
CREATE CURSOR sicks (personid i, disease c(15))
>>INSERT INTO sicks VALUES (883554,'rabies')
>>INSERT INTO sicks VALUES (128748,'inflammation')
>>INSERT INTO sicks VALUES (123654,'angina')
>>INSERT INTO sicks VALUES (146528,'angina')
>>INSERT INTO sicks VALUES (918457,'rabies')
>>INSERT INTO sicks VALUES (585846,'rabies')
>>INSERT INTO sicks VALUES (931694,'inflammation')
>>INSERT INTO sicks VALUES (123654,'inflammation')
>>INSERT INTO sicks VALUES (325896,'angina')
>>INSERT INTO sicks VALUES (513258,'rabies')
>>INSERT INTO sicks VALUES (652845,'drill')
>>INSERT INTO sicks VALUES (254636,'angina')
>>INSERT INTO sicks VALUES (842169,'angina')
>>INSERT INTO sicks VALUES (195499,'rabies')
>>INSERT INTO sicks VALUES (585842,'rabies')
>>INSERT INTO sicks VALUES (128788,'drill')
>>INSERT INTO sicks VALUES (124558,'angina')
>>INSERT INTO sicks VALUES (931695,'inflammation')
>>
>>PS
>>If it's possible, I prefer to get it by count group (2sequential persons for same disease,3,4..)
>>
>>Big thank's
>

>Try:
>
>SELECT * FROM sicks;
>	WHERE exist (SELECT personID FROM sicks auxSicks;
>					WHERE 	auxSicks.personID - 1 = sicks.personID;
>						AND auxSicks.disease = sicks.disease;
>				);
>		OR exist (SELECT personID FROM sicks auxSicks;
>						WHERE 	auxSicks.personID + 1 = sicks.personID;
>							AND auxSicks.disease = sicks.disease;
>				);
>	INTO CURSOR crsSicks
>
>BROWSE NORMAL
>
>I hope this helps you.
Thank you
Chaim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform