[thelist] SQL to return one result for duplicate values
rudy
r937 at interlog.com
Mon Apr 29 20:22:01 CDT 2002
> SELECT word_value
> , min(word_id) as first_word_id
> FROM table_name
> GROUP BY word_value
>
> How's that?
pretty sweet, paul
erik, you did say you wanted a query to return just those results, and
paul's query will do that very nicely -- i guess i was reading too much
into your questions, and assumed you'd be interested in a query to remove
duplicates
note: if you want any other columns besides word_id, it gets a little
trickier
in that case, try
select word_id, word_value, word_type, word_date
from thetable XX
where word_id =
( select min(word_id)
from thetable
where word_value = XX.word_value )
the above assumes you are testing duplicates based on just word_value, and
are interested in only the row with the lowest id in that group
rudy
More information about the thelist
mailing list