On Mon, 23 Oct 2006 16:30:46 +0200, "salvatore scarantino"
If these rows are really duplicates, it wouldn't matter which
one was shown, wouldn't it? Apparently, they are not the same,
so they aren't duplicate at all (*).
There is no strict rule which values will be shown for columns
not mentioned in the GROUP BY clause. GROUP BY is meant to be
used together with aggregate functions on every one of those
columns, like min(), max(), floor(), ceiling(), avg(), sum()
There probably won't be something like first or last, as the
order of rows in any result set is undefined, unless forced by a
ORDER BY clause, but I may be wrong at that.
Some SQL dialects even reject a query containing columns without
There is no order, you get only one result row for every ID.
As said, any column not mentioned in the GROUP BY clause will
have an unpredictable value. Make it predictable with for
example MAX() or MIN().
You can order the resulting rows as usual with ORDER BY.
(*) By the way, I think you are struggling with a less than
optimal schema. Your values aren't uniquely identified by a key.
That usually leads to this kind of questions. Feel free to ask
help, or, even better, Google for "database design normalisation
rdbms" (without the quotes). There is some excellent material
You're welcome, hope this helps.
c[_] When you say 'I wrote a program that crashed Windows' people just stare at you
blankly and say 'Hey, I got those with the system for free' (Linus Torvalds) (#29)