Won't work. You can't have a column in the order by that is not in the
group by and TOP 1 only returns the first record, not the first record
for each articlIssueID. I started by replying to this mail this morning
thinking "this should be easy", but I didn't find a solution. I
discussed it with my colleagues and they had no solution either. Maybe
some SQL guru can find one, but nobody in my company did. The only
solution I could come up with was: write a stored procedure.

Pascal

> -----Original Message-----
> From: Deanna Schneider [mailto:[EMAIL PROTECTED]
> Sent: maandag 29 maart 2004 15:39
> To: CF-Talk
> Subject: Re: SQL grouped query help
>
> ----- Original Message -----
> From: "Ryan Sabir"
> > Now, I want to select only the latest article from each issue in a
> > single query. Any ideas how I would do this?
>
> Try something like this:
> <cfquery...>
> SELECT     articleTitle, articleDate, articleIssueID
> FROM        myArticles
> WHERE    articleID IN (SELECT TOP 1 articleid FROM myArticles GROUP BY
> articleIssueID ORDER BY articledate DESC ) </cfquery>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to