> Hello, > > I'm working on a project where records will be added to a single > table, and each record will be assigned to one of six categories > (using a category column). Is there a way I can do a single query to > pull the most recent record from each of the six categories? Or is > my only option to do queries of queries on my CF template?
Not sure of your actual table structure or database but you could possibly use the UNION operator for this. Assuming your database is MS SQL Server and there is some column in your table that you can use to determine the "most recent" (such as an ID or timestamp column): SELECT TOP 1 * FROM tbl WHERE category = 'A' ORDER BY ID DESC UNION SELECT TOP 1 * FROM tbl WHERE category = 'B' ORDER BY ID DESC ... and so on for all the categories. If you had six categories, this would return six rows, one per category, with the "most recent" entry for each category. HTH, Stephen > Thanks, > Jonathan > ________________________________________________________ > Jonathan Mauney > Manager, Digital Media Properties / Web Application Developer > 1110 WBT AM / 107.9 the LINK (WLNK-FM) / Jefferson-Pilot Radio > Network Jefferson-Pilot Communications Co. One Julian Price Place > Charlotte, North Carolina 28208 704.374.3862 [voice] 704.374.3884 > [fax] [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> [email] > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ~| Archives: > http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 > Subscription: > http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&for > umid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > > Host with the leader in ColdFusion hosting. > Voted #1 ColdFusion host by CF Developers. > Offering shared and dedicated hosting options. > www.cfxhosting.com/default.cfm?redirect=10481 > > Unsubscribe: > http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=2137. > 2057.4 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

