SQL Server查询某字段去重后取前n条
distinct和top n一起使用, 其语法及例子如下:
select distinct top 5(name) from orders
本文介绍了如何在SQLServer中结合使用DISTINCT和TOPN关键字来查询特定字段的唯一值,并限制返回结果的数量。示例查询为:SELECT DISTINCT TOP 5 name FROM orders,该查询将返回orders表中name字段的前五个不重复值。
SQL Server查询某字段去重后取前n条
distinct和top n一起使用, 其语法及例子如下:
select distinct top 5(name) from orders
996
1854

被折叠的 条评论
为什么被折叠?