hey all
having some trouble with this if else. getting errors like "error 209 - ambiguous column name emEmployee" this is because column emEmployee is in all of the joined tables. thanks for the help.
IF EXISTS (Select * From tblbonus WHERE emSelect1 = 'Salary')
Begin
Select tblbonus.emEmployee, (directhours - 0) % ((weeksworked * 40) - vacationused) AS productivity
FROM tblbonus INNER Join tbldirecthours on (emEmployee = ldEmployee) Inner join tblweeksworked on (ldEmployee = emEmployee) Inner Join tblvacationused on (emEmployee = ldEmployee)
END
ELSE
BEGIN
SELECT tbldirecthours.ldEmployee, directhours / paidhours as productivity FROM tbldirecthours RIGHT join tblpaidhours on (ldEmployee = ldEmployee)
GROUP BY ldEmployee, directhours, paidhours
END
having some trouble with this if else. getting errors like "error 209 - ambiguous column name emEmployee" this is because column emEmployee is in all of the joined tables. thanks for the help.
IF EXISTS (Select * From tblbonus WHERE emSelect1 = 'Salary')
Begin
Select tblbonus.emEmployee, (directhours - 0) % ((weeksworked * 40) - vacationused) AS productivity
FROM tblbonus INNER Join tbldirecthours on (emEmployee = ldEmployee) Inner join tblweeksworked on (ldEmployee = emEmployee) Inner Join tblvacationused on (emEmployee = ldEmployee)
END
ELSE
BEGIN
SELECT tbldirecthours.ldEmployee, directhours / paidhours as productivity FROM tbldirecthours RIGHT join tblpaidhours on (ldEmployee = ldEmployee)
GROUP BY ldEmployee, directhours, paidhours
END