Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 284
EmreAltun Avatar asked Apr 08 '12 20:04

EmreAltun


1 Answers

try

SELECT carBrand , carYear ,carModel 
FROM Cars 
GROUP BY carBrand , carYear ,carModel;
like image 69
Yahia Avatar answered Oct 09 '22 12:10

Yahia