aaronbrettuk
New member
- Local time
- Today, 13:58
- Joined
- May 2, 2025
- Messages
- 3
Hi All
Can someone help me find the Syntax error in this SQL please? It's in MS Access - Syntax Error (missing operator) in query expression
Can someone help me find the Syntax error in this SQL please? It's in MS Access - Syntax Error (missing operator) in query expression
SQL:
SELECT O.offset,
O.monthenddate,
R.id
AS RoleID,
R.roletitle,
R.grade,
R.costcentreid,
CC.costcentrename,
CC.costcentreowner,
ER.id
AS EmpRoleID,
ER.payrollid,
ER.startdate
AS RoleStartDate,
"rolestatustext"
AS RoleStatus,
"roletypetext"
AS RoleType,
ER.enddate
AS RoleEndDate,
ER.employmenttype,
ER.weeklyhours,
ER.weeklyhours / 37.5
AS FTE,
E.id,
E.firstname,
E.lastname,
EP.employercontr,
( QSL.newsalary * ( 1 + Getfuturepayrisepct(O.monthenddate) / 100 ) ) /
12 AS
CurrentSalary,
G.bonus
AS GradeBonusPct,
(SELECT TOP 1 bonuspayout
FROM tblbonuspayout AS BP
WHERE BP.bonusyear <= Getfiscalyear(O.monthenddate)
ORDER BY BP.bonusyear DESC)
AS BonusPayoutPct,
QSL.newsalary * ( 1 + Getfuturepayrisepct(O.monthenddate) / 100 ) / 12 *
G.bonus
/ 100 * (SELECT TOP 1 bonuspayout
FROM tblbonuspayout AS BP2
WHERE BP2.bonusyear <= Getfiscalyear(O.monthenddate)
ORDER BY BP2.bonusyear DESC) / 100
AS BonusAmount,
(SELECT TOP 1 niweeklypaycap
FROM tblnirates AS NIcap
WHERE NIcap.nieffectivedate <= O.monthenddate
ORDER BY NIcap.nieffectivedate DESC) * 52 / 12
AS MonthlyPayCap,
(SELECT TOP 1 niemployerrate
FROM tblnirates AS NIrate
WHERE NIrate.nieffectivedate <= O.monthenddate
ORDER BY NIrate.nieffectivedate DESC)
AS NIEmployerRate,
Iif(QSL.newsalary / 12 > (SELECT TOP 1 niweeklypaycap
FROM tblnirates AS NIcap2
WHERE NIcap2.nieffectivedate <= O.monthenddate
ORDER BY NIcap2.nieffectivedate DESC) * 52 /
12, (
QSL.newsalary / 12 - (SELECT TOP 1 niweeklypaycap
FROM tblnirates AS NIcap3
WHERE NIcap3.nieffectivedate <= O.monthenddate
ORDER BY NIcap3.nieffectivedate DESC) * 52 / 12 )
* (
SELECT TOP 1 niemployerrate
FROM tblnirates AS NIrate2
WHERE NIrate2.nieffectivedate <= O.monthenddate
ORDER BY NIrate2.nieffectivedate DESC) / 100, 0)
AS EmployerNI
FROM (SELECT offset,
Dateserial(Year(Dateadd("m", offset, Date())),
Month(Dateadd("m", offset, Date())) + 1, 0) AS MonthEndDate
FROM tbloffsets) AS O
LEFT JOIN tblemployeeroles AS ER
ON Nz(ER.startdate, Getnewstarterdate()) <= O.monthenddate
AND Nz(ER.enddate, #9999 / 12 / 31 # ) >= O.monthenddate
LEFT JOIN tblroles AS R
ON ER.roleid = R.id
LEFT JOIN tblcostcentre AS CC
ON R.costcentreid = CC.costcentreid
LEFT JOIN tblemployees AS E
ON ER.payrollid = E.payrollid
LEFT JOIN tblemployerpension AS EP
ON EP.employeecontr = E.pensioncontr
LEFT JOIN qrylatestsalarybydate AS QSL
ON ER.roleid = QSL.roleid
LEFT JOIN tblgrades AS G
ON G.grade = R.grade
ORDER BY O.offset;
Last edited: