I'm new to advanced SQL. I have a query that I need to add a variable. It needs to connect to an employee table and only show a record for that specific employeeId. This is Outsystems and advanced SQL query. Any ideas?
This is what I need to add: Employee.EmployeeId = EmployeeId or EmployeeId = NullIdentifier()
Existing query that I need to add the above to some how:
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