SqlServer中Distinct和Top一起使用

SqlServer中Distinct和Top一起使用

SELECT distinct top  2  LastName FROM [dbo].[Employees] order by LastName

 distinct要放到top前面,这样取出的结果是先将数据Distinct去重复,然后再取其中的前两行

posted @ 2022-08-05 08:36  江南小镇的一缕阳光  阅读(346)  评论(0)    收藏  举报