--用OUTER APPLY select b.* FROM a表 a OUTER APPLY () * from b表 WHERE [Name] = a.[AName] ORDER BY BNo desc) b 总结: . 理解 CROSS APPLY 与 OUTER APPLY(个人理解) ) CROSS APPLY 的意思是“交叉应用”,在查询时首先查询左表,然后右表的每一条记录跟左表的当前记录进行匹配.匹配成功则将左表与右表的记录合并为一条记录输出:匹配失败则抛弃左表与右表的记录.(与
--重复ID的记录,只显示其中1条 --生成原始表 select * into #tempTable from ( select '1' as id ,'a' as name union all select '1' as id ,'b' as name union all select '2' as id ,'c' as name union all select '2' as id ,'d' as name ) a --查询原始表 select * from #tempTable --增加序
常见数据库SELECT结果只显示前几条记录方法汇总 为了查看数据表中的数据情况.经常会遇到想让查询结果只显示N行,比如只显示10行的情况.不同的数据库有不同的关键字和SELECT实现语法. 1.SQL Server数据库select top 10 * from table_name; 2.DB2数据库select * from table_name fetch first 10 rows only; 3.Oracle数据库select * from table_name where rownu