Hey there peoples, anyone else working the weekend shift? I gotta SQL question..
Imagine a database of news articles, each with an individual date, but they are also grouped into issues, so a select might look like: SELECT articleTitle, articleDate, articleIssueID FROM myArticles ORDER BY articleIssueID Now, I want to select only the latest article from each issue in a single query. Any ideas how I would do this? The dodgy way would be to go: <CFQUERY name="blah"> SELECT articleTitle, articleDate, articleIssueID FROM myArticles ORDER BY articleIssueID </CFQUERY> <CFLOOP query="blah"> <CFQUERY name="latestArticle"> SELECT TOP 1 articleTitle, articleDate, articleIssueID FROM myArticles WHERE articleIssueID = #articleIssueID# ORDER BY articleDate DESC </CFQUERY> ... </CFLOOP> But that means doing a query on every iteration of the loop.. I'm sure theres a way to do this in one query using some sort of grouping, but it escapes me... thanks... ----------------------- Ryan Sabir Newgency Pty Ltd 2a Broughton St Paddington 2021 Sydney, Australia Ph (02) 9331 2133 Fax (02) 9331 5199 Mobile: 0411 512 454 http://www.newgency.com/index.cfm?referer=rysig --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
