You need to order by both, first the item on which you want to group,
then the item that you want sorted within that group. I've used a left
outer join just incase you have events that do not have dates entered.

Hopefully, I've not flubbed this up, and this works for you:

<cfquery name="myevents" datasource="mydsn">
    select e.eventname, d.eventdates
    from event e left outer join eventdates d on e.eventid=d.eventid
    order by e.eventname, d.eventdate desc
</cfquery>

<cfoutput query="myevents" group="eventname">
    <p>
    #eventname#
    <cfoutput><br />#dateformat(eventdates,"mm/dd/yyyy")#</cfoutput>
    </p>
</cfoutput>

Cheers,
Kris


> I'm gonna try this again as while I slept last night my previous post
> turned into a discussion of SQL best practices and did not give the
> answer needed. But that's probably because I didn't explain well
> enough. Ordering by EventID will not work. Nor will ordering by date.
> Maybe a little more data will help.
>
> EventID, EventName
> 1 | TestEventOne
> 2 | TestEventTwo
> 3 | AThirdEvent
>
> EventID | EventDates
> 1 | 9/10/2006
> 1 | 9/20/2006
> 2 | 9/15/2006
> 3 | 9/30/2006
>
> <!--- Desired results --->
> AThirdEvent
>   9/30/2006
>
> TestEventOne
>   9/20/2006
>   9/10/2006
>
> TestEventTwo
>  9/15/2006

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

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