Thanks Stephen, your solution works fine. I had tried that and couldn't get it to work properly (group by issue).
James E Harvey Hanover Shoe Farms, Inc. M.I.S./Corresponding Officer Off: 717-637-8931 fax: 717-637-6766 email: [EMAIL PROTECTED] -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Russell Sent: Friday, June 20, 2008 2:11 PM To: ProFox Email List Subject: Re: Combine select statments On Fri, Jun 20, 2008 at 12:43 PM, Jim Harvey <[EMAIL PROTECTED]> wrote: > I'm trying to retrieve data from the most recent treatment, and I'd like to > try and do it in one select statement. > > This works with two, how to combine? > > SELECT comp_no, MAX(date_serv) as maxdate FROM health WHERE comp_no = > thisform.r_comp GROUP BY comp_no INTO CURSOR temp > > > SELECT health.comp_no, health.item_no, health.descript FROM health WHERE > comp_no = thisform.r_comp AND date_serv = temp.maxdate > ----------------- SELECT health.comp_no, health.item_no, health.descript, Max(health.Date_srv) FROM health WHERE comp_no = thisform.r_comp group by health.comp_no, health.item_no, health.descript I hope that your health.descript is a look up and not a free form text column. If it is you could fake it with a top 1 SELECT top 1 health.comp_no, health.item_no, health.descript, health.Date_srv FROM health WHERE comp_no = thisform.r_comp order by helath.date_srv desc -- Stephen Russell Sr. Production Systems Programmer Mimeo.com Memphis TN 901.246-0159 --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

