with cte as (select *,rn=row_number()over(partition by 标题 order by getdate()))select top 10 * from cte where rn=1
with cte as (select *,rn=row_number()over(partition by 标题 order by getdate()))select top 10 * from cte where rn=1
select top 10 * from table where 标题 in(select distinct 标题 from table ) 不知道这个适不适合?
不是标题吧,应该是列,不重复的数据。 取前10吧,那应该按什么排序呢! 因为使用distinct top 10 * ,后面必须有order by --这里暂为按id排序 SELECT DISTINCT TOP 10 * FROM TABLENAME order by id asc
是列,不重复的数据。 取前10位 使用distinct top 10 * ,后面必须有order by with cte as (select *,rn=row_number()over(partition by 标题 order by getdate()))select top 10 * from cte where rn=1
一个表的标题不可能重复,您直接查。
with cte as (select *,rn=row_number()over(partition by 标题 order by getdate()))select top 10 * from cte where rn=1
不知道这个适不适合?
取前10吧,那应该按什么排序呢!
因为使用distinct top 10 * ,后面必须有order by
--这里暂为按id排序
SELECT DISTINCT TOP 10 * FROM TABLENAME order by id asc
取前10位
使用distinct top 10 * ,后面必须有order by
with cte as (select *,rn=row_number()over(partition by 标题 order by getdate()))select top 10 * from cte where rn=1