> why do you have to use a single select statement? Thats pretty 
> limiting there..

1) To see if it can be done
2) It seemed that it may perform best to make a single pass at the table
as opposed to two passes.  (That might not be true-- it was just a
thought)

The query below works, but does not return a distinct list of orders.
If multiple products were added at the same time, I get all of them.
I'm really looking for a top 1 sort of deal I guess.

~Brad

-----Original Message-----
From: Greg Morphis [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 28, 2007 11:47 AM
To: CF-Talk
Subject: Re: SOT: SQL Question

select t.order_num, t.product_name, t.datetime_created
from test t,
(
select order_num, max(datetime_created) maxdt
  from test
  group by order_num
)  t2
where t2.order_num = t.order_num
and t2.maxdt = t.datetime_created



1 query, but 2 selects = gets what you want

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion is delivering applications solutions at at top companies 
around the world in government.  Find out how and where now
http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289755
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to