SQL CROSS APPLY 用法

有两个表,分类表,和文件表

两个表的关联地段是分类ID

要求,查询每个分类表下面最后更新的三条文件表数据

select * from Category as c
cross apply 
(select  top 3 * from FileCategory as rc where c.Id = CategoryId order by rc.UpdateTime desc) as rc

  

 

posted @ 2021-01-25 18:16  jasonlai2016  阅读(457)  评论(0编辑  收藏  举报