You should use nested query. I don't like this ugly solution and there may be performance penalty. But I am pretty sure this will give you the same result.
*!* Assuming that comp_no is int or number type. SELECT health.comp_no, health.item_no, health.descript, health.date_serv FROM health WHERE comp_no = thisform.r_comp AND STR(comp_no,10,0)+DTOS(date_serv) in ( select a.f1 from ( select STR(comp_no,10,0)+DTOS(MAX(date_serv)) as f1, comp_no from health group by comp_no) as a) Regards, Namgeun On Fri, Jun 20, 2008 at 2:11 PM, Stephen Russell <[EMAIL PROTECTED]> wrote: > 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.

