Surprisingly it is difficult to use TOP and DISTINCT together in SQL.
This will not work:
select top 2 distinct t.ID as tID, t.Name as tName from Table1 order by tID
It can be replaced by something like this to work:
select top 2 * from
(select distinct t.ID as tID, t.Name as tName from Table1 t) y
order by tID
Also see some other web links, such as
Here
select distinct top x fields from table ;
ReplyDelete