Sql 2008 select with one unique column

How can I select more columns from a table, but one column to be unique ?

I have this query
SELECT Id, Make, Model, Year FROM [VehicleSpecs]

and I want to return fields with unique Make
LVL 2
evo_xAsked:
Who is Participating?
 
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
This would do:
SELECT Id, Make, Model, Year
FROM (
SELECT Id, Make, Model, Year, row_number() over ( partition by Make order by ID) rnum
FROM [VehicleSpecs]) temp
WHERE rnum = 1

Open in new window

0
 
santoshmotwaniCommented:
SELECT distinct Make, ID, Model, Year FROM [VehicleSpecs]
0
 
evo_xAuthor Commented:
Thanks !
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
Welcome..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.