in reply to Re: mysql sorting
in thread mysql sorting
Actually, group by does very little in this case. Sort would work just fine for this situation (see monarch's answer ... that's the type of logic that I would use.)
In these situations, I think the logic outside of the SQL is more important for the final presentation than something you can do through SQL.
So, if 'group by' isn't useful here, what is it really good for? Well, it's good for when you're trying to aggregate records, such as the following.
SELECT groupfield, SUM(somedata) FROM tablename GROUP BY groupfield
or
SELECT groupfield, MAX(somedata) FROM tablename GROUP BY groupfield
In these situations, you only get one row returned per 'group'. There's also the rarely used (in my experience) HAVING clause.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: mysql sorting
by bpphillips (Friar) on Jun 01, 2005 at 13:07 UTC |