我是高级 SQL 的新手。我有一个需要添加变量的查询。它需要连接到一个员工表,并且只显示该特定员工 ID 的记录。这是 Outsystems 和高级 SQL 查询。有任何想法吗?
这是我需要添加的: Employee.EmployeeId = EmployeeId 或 EmployeeId = NullIdentifier()
我需要将以上内容添加到某些方式的现有查询:
Select
EMPLOYEEDISPLAYNAME ,
ISNULL(Sick.Total,0.00) as SickValue,
ISNULL( Vacation.Total,0.00) as VacationValue
from
{Employee}
left join
( Select
EMPLOYEEID,
Sum( DEPOSITVALUE ) - Sum( WITHDRAWLVALUE ) as Total
from
{TimeOffRegisterEntry}
join {TimeOffRegister}
on {TimeOffRegisterEntry}.TimeOffRegisterId = {TimeOffRegister}.TimeOffRegisterId
join {TimeOffYear}
on {TimeOffRegister}.TimeOffYearId = {TimeOffYear}.TimeOffYearId
where
TIMEOFFTYPE = @VacationType
and {TimeOffYear}.[TimeOffYearId] = @Year
group by
EMPLOYEEID
having
Sum( DEPOSITVALUE ) - Sum( WITHDRAWLVALUE ) < 0
) as Vacation
on {Employee}.EmployeeId = Vacation.EMPLOYEEID
left join
( Select
EMPLOYEEID,
Sum( DEPOSITVALUE ) - Sum( WITHDRAWLVALUE ) as Total
from
{TimeOffRegisterEntry}
join {TimeOffRegister}
on {TimeOffRegister}.TimeOffRegisterId = {TimeOffRegisterEntry}.TimeOffRegisterId
join {TimeOffYear}
on {TimeOffRegister}.TimeOffYearId = {TimeOffYear}.TimeOffYearId
where
TIMEOFFTYPE = @SickType
and {TimeOffYear}.[TimeOffYearId] = @Year
group by
EMPLOYEEID
having
Sum( DEPOSITVALUE ) - Sum( WITHDRAWLVALUE ) < 0
) as Sick
on {Employee}.EmployeeId = Sick.EMPLOYEEID
where
Vacation.total is not null
or Sick.Total is not null