I think this will give you what you want.

select top 1 t2.pk_CasacAppt from tblCasacCM left outer join tblCasac t2
on t1.pk_CasacAppt = t2.pk_CasacAppt
left outer join tblContacts t3 on t1.pk_CMAppt = t3.CMAppt
where pk_uniqueID = #Variable#
order by t2.CasacDate desc

John Hancock

-----Original Message-----
From: Julie Clegg [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 1:01 PM
To: CF-Talk
Subject: SQL Newbie - Help!!!!!


Hello,

I have a large sql query I need to write and am having some problems with
it.  I have broken it down into several sections...the fist section I cannot
figue out involves 3 table which I have listed below along with the main
fields I need to deal with in parenthasis:

tblContacts
(pk_uniqueID, CMAppt)

tblCasacCM
(pk_CMAppt, pk_CasacAppt)

tblCasac
(pk_CasacAppt, CasacDate)


In the tblCasac, there are many pk_CasacAppt's that relate to only one
CMAppt.  I need to capture the most recent pk_CasacAppt(using CasacDate) for
a particular CMAppt.
Hope this all makes sense,,,any suggestions would be greatly appreciated...


TIA,

Julie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to