[thelist] sql de-doupe

r937 rudy at r937.com
Sat Feb 2 04:48:39 CST 2008

> modelA  cat1
> modelA  cat2
> modelB  cat1
> modelB  cat2
> Out of those 4, I need:
> modelA  whatever_cat_comes_first
> modelB  whatever_cat_comes_first

unfortunately there is no such thing as "comes first" in a relational 

(despite this, msaccess has a FIRST function, but SQL Server doesn't)

how about the lowest category?

   select model, min(cat) from daTable group by model

simple, yes?

More information about the thelist mailing list