SQL: distinct on single field

Ivan Smahin ivan_smahin at valentina-db.com
Wed Mar 22 10:35:03 CST 2006


Hello Heinrich,

Wednesday, March 22, 2006, 1:45:07 AM, you wrote:

> Hi to all,

> is it possible to use DISTINCT only on a single field instead of all
> selected fields?

> e.g.:

> id ProductCode Color
> 1 product_a red
> 2 product_a blue
> 3 product_b green

> SELECT DISTINCT ProductCode, Color, id FROM Products

->> all records are returned because id and color are different

> but I'd like to make only ProductCode DISTINCT to get only the first
> apperance of  product_a


SELECT ProductCode, Color, id FROM Products Group By ProductCode



-- 
Best regards,
 Ivan                            mailto:ivan_smahin ÎÁ valentina-db.com



More information about the Valentina mailing list