我知道简单查询的查询执行顺序。
但是,我对理解此查询中的确切执行顺序感到困惑:
select
M.DateKey As DateKey ,
PersonnelCode As PersonnelCode,
Isnull((select top 1 BranchCode
from [Financial].[viwPersonnelLocation]
where PersonnelCode = p.PersonnelCode and DateKey <= M.DateKey
order by DateKey desc)
,p.BranchCode) As BranchCode,
Isnull((select top 1 CertficateCode
from [Financial].[viwPersonnelEducation]
where PersonnelCode = p.PersonnelCode and DateKey <= M.DateKey
order by DateKey desc)
,p.Educationcode) As Educationcode
from (select DateKey,MonthOfYearKey,EDATE
from [Common].[DimTime]
where LastDayOfMonthKey = 1) M
Inner Join
[Financial].[viwPersonnelInfo] As P
on m.DateKey >= p.DateOfEmployeement
where (m.DateKey <= p.DateOfLeave) or (p.DateOfLeave='' or p.DateOfLeave is null) and m.EDATE <= getdate()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
81 次 |
最近记录: |