how to use DISTINCT when I have multiple column in sql server

后端 未结 4 1677
半阙折子戏
半阙折子戏 2020-12-16 02:04

I have the following query:

select carBrand, carYear, carModel from cars;

what I want is to get only different car names.

I wrote t

4条回答
  •  不知归路
    2020-12-16 02:34

    DISTINCT works on the entire row, not a specific column. If you want to get the unique names, select only that column.

    SELECT DISTINCT carBrand FROM Cars
    

提交回复
热议问题