Re: Query: Order for the Earliest Latest date

2006-01-24 Thread Dan Baker
"Peter Brawley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan, > >>I'm trying to generate a list of sites that HAD a support incident within >>a known date range, and order them so that the site that has the OLDEST >>support call is FIRST in the list. > > It's the (oft-asked-

Re: Query: Order for the Earliest Latest date

2006-01-24 Thread Peter Brawley
Dan, I'm trying to generate a list of sites that HAD a support incident within a known date range, and order them so that the site that has the OLDEST support call is FIRST in the list. It's the (oft-asked-for) groupwise-max query. Here's one way, assuming you have MySQL 4.1 or later ... S

Re: Query: Order for the Earliest Latest date

2006-01-24 Thread Greg Fortune
In addition to the id_Site, you also need to grab the MAX(Time) so you have something to sort by. This requires a little trick known as a "groupwise maximum." See http://dev.mysql.com/doc/mysql/en/example-Maximum-column-group-row.html for an explanation and some examples. Greg Fortune On Tu

Query: Order for the Earliest Latest date

2006-01-24 Thread Dan Baker
[GENERAL INFO] I have two tables I'm working with. One table (Sites) contains contact information for every customer site that we deal with. The other table (Incidents) contains all the support calls we've made. [QUERY] I'm trying to generate a list of sites that HAD a support incident within a