I have a table which contain identity primary key id, CNum, CUID and some other columns. I want to select distinct records based on CNum and CUID, in other words if two records have the same CNum and CUID I want to get the top one, I tried to group by but it will not work since the want the whole row.
with a as (SELECT distinct CNum, CUID
FROM Con)
select c.CNum from Con c inner join
a on a.CNum = c.CNum
and a.CUID= c.CUID
order by id
This approach still gets duplicate records.
Anyone knows how to solve the problem?