I am writing a query that requires the use of an if else statment. I have written the statement and tested it but i can not make it work as part of a larger query. Does anyone know how i could do this?
--check to see if the person has a leaving date
if (select max(c.working_to) from v_ssd_resource c,
m_ssd_resource_Cost_centre_history a
where a.consultant = c.consultant) is null
begin
--if not then select the period(monthno) where the month from the changedate = the actualmonthno
(select d.monthno from m_ssd_periods d, m_ssd_resource_Cost_centre_history a
where datepart(mm,a.changedate) = d.actualmonthno)
end
else
--if there is leaving date then select the period (monthno) where the month from the
--working_to date = the actualmonthno
begin
(select d.monthno from m_ssd_periods d, v_ssd_resource c
where datepart(mm,c.working_to) = d.actualmonthno)
end
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.