Scot,

>I want to generate a report that outputs the latest record modified for each 
>org_ID based on the last_mod field.
>
>The final report should show each org_id once with the latest record based on 
>the last_mod field.
>
>Here is my existing code:
>
><cfquery name="filespec_dates" DATASOURCE="#application.aptools#">
>SELECT a.org_id, a.last_mod, a.title, a.url
>FROM bb_file_spec a
>WHERE a.org_id IS NOT NULL and 
>and exists(select b.org_id from bb_organization b where b.org_id = a.org_id)
>order by a.org_id
></cfquery>
>
What DB is this?

If this is mySQL then

SELECT a.org_id, a.last_mod, a.title, a.url
FROM bb_file_spec a
   INNER JOIN bb_organization b ON b.org_id = a.org_id
WHERE a.org_id IS NOT NULL 
ORDER BY a.last_mod,a.org_id
LIMIT 1

SQL Server/Access would be something like this

SELECT TOP 1 a.org_id, a.last_mod, a.title, a.url
FROM bb_file_spec a
   INNER JOIN bb_organization b ON  a.org_id = b.org_id 
WHERE a.org_id IS NOT NULL 
ORDER BY a.last_mod,a.org_id


Hope this helps

Regards

Stephen



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Purchase Contribute 3 from House of Fusion, a Macromedia Authorized Affiliate 
and support the CF community.
http://www.houseoffusion.com/banners/view.cfm?bannerid=53

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:775
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to