SQL Server Select Distinct

Posted by homam on Stack Overflow See other posts from Stack Overflow or by homam
Published on 2010-05-18T07:51:38Z Indexed on 2010/05/18 8:00 UTC
Read the original article Hit count: 337

Filed under:
|
|
|
|

I want to write a query like this:

For a table that has these columns: ColA ColB ColC, ColD

select first(ColA, ColB, ColC, ColD) distinct(ColB, ColC) from table order by ColD

The query is supposed to order the table by ColD, then group the results by the combination of ColB and ColC (they may have different data types) and returns the first rows (with all the columns of the table) in the groups.

How is it possible in MS SQL Server 2005?

© Stack Overflow or respective owner

Related posts about sql

Related posts about distinct