>This should be pretty simple actually =)
>
>
>SELECT DISTINCT
>       Order_num,
>       datetime_created,
>       (SELECT product_name FROM tableName WHERE order_num = a.ordernum
>AND record_ID = (SELECT MAX(record_ID) FROM tableName WHERE order_num =
>a.order_num)) as LastProduct
>FROM
>       tableName A

Didn't they mention the table has something like 11 million rows. With so many 
rows I would think a derived table would be than a subquery.  Though 2005 might 
be smart enough to optimize it.  I don't know.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Enterprise web applications, build robust, secure 
scalable apps today - Try it now ColdFusion Today
ColdFusion 8 beta - Build next generation apps

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289763
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