sql - SQL Server 多连接
问题描述
谁能解释这个查询有什么问题?
select A.*
from GDPApplication A,
(select top(e.ToDate) *
from EducationalQualification e
where e.Id = A.Id
order by e.ToDate desc
) B left outer join
EnglishTest eng on A.Id = eng.FKApplicationId
解决方案
TOP
子句需要数字参数,例如TOP (1)
为了获取 N.. 根据ordering
定义的顶部位置的行数
select A.*
from GDPApplication A cross apply (
select top (1) e.ToDate, *
from EducationalQualification e
where e.Id = A.Id
order by e.ToDate desc
) B left outer join
EnglishTest eng on A.Id = eng.FKApplicationId
推荐阅读
- reactjs - Redux - 从后端获取初始状态 - 这是正确的方法吗?
- swift - 在用户输入上添加结构
- python-3.x - Python3:找到除以10后余数最大的数(第二个答案的while循环中的一些错误)
- python - 重复for循环读取文件直到满足条件
- git - 离线时如何快进origin/master?
- django - 如何使用 Postman 使用带有参数的 Django api?
- mysql - 续集的模型定义中的onUpdate不起作用
- java - 简单数据库应用程序发生“IO 错误:连接被拒绝(连接被拒绝)”拒绝
- c - 使用 Union 中存在的函数指针执行 shell 代码
- python - 用于在表中查找元素的 UDF