Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this does not work
Message
From
24/08/2006 18:52:41
 
 
To
24/08/2006 04:18:25
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01148070
Message ID:
01148416
Views:
17
Thanks for that Fabio.
i had to make small changes to run suggested query work. it runs fine but missing out some patients.
i know for 2 sure that i've 2 records that matches my criteria but this query returns only first one it finds. looks like "Last_result_date" always same in join!!

SELECT ;
master.NHI as Patient_Numbers_UR_Number,;
PADR(mastername ('sk', master.name, master.surname, master.firstnames, master.knownname),60) as Name_Address_Full_Known_Name,;
Last_result_date,;
rp1.value AS Result,rp1.pkey;
from master;
inner join res_pat as rp1 on rp1.master = master.pkey;
inner join (select master,MAX(resdate) Last_result_date from res_pat group by master) last;
on rp1.master = last.master ;
where rp1.resdate=last.Last_result_date AND rp1.pkey in ; && simplified this part: put the IN into the inner join
(select res_pat1.pkey FROM master,;
test_pat test_pat1, test test2, res_pat res_pat1; && put join here !!!!!
WHERE ;
(UPPER (PADR(test2.Name,30)) LIKE "BMI");
AND year (res_pat1.Resdate) = 2005 AND;
(master.status = 0 AND test_pat1.MASTER = master.PKEY AND test_pat1.status < 2;
AND test_pat1.TEST = test2.PKEY AND test2.status < 2;
AND res_pat1.TEST_PAT = test_pat1.PKEY AND res_pat1.status < 2))
Previous
Reply
Map
View

Click here to load this message in the networking platform