SELECT * FROM TB1 ORDER BY [name]
id name
------ ----------
1 A
5 A
6 A
2 B
3 B
4 C
(6 行処理されました)
----------------------------------------------------------------------------
select * from tb1 as tb2 where [id] = (select min([id]) from tb1 where [name] = tb2.[name])
********************************
id name
------ ----------
1 A
2 B
4 C
(3 行処理されました)
----------------
select tb1.[id],isnull(tb2.[name],'') as [name] from tb1
left join
(select min([id]) as [id],[name] from tb1 group by [name]) tb2
on tb1.[id]= tb2.[id]
order by tb1.[name]
********************************
id name
------ ----------
1 A
5
6
2 B
3
4 C
(6 行処理されました)