How to use DISTINCT when I have multiple column in SQL Server?

distinct, sql, sql-server

Solution

Try thi:

SELECT carBrand, carYear, carModel 
FROM Cars 
GROUP BY carBrand, carYear, carModel;

Problem

I have the following query: ``` SELECT carBrand, carYear, carModel FROM Cars; ``` What I want is to get only different car names. I wrote this, but it is not what I want: ``` SELECT DISTINCT carBrand, carYear, carModel FROM Cars; ``` How can I solve this problem?

Original source

Related problems