Click here to Skip to main content
14,635,225 members
Rate this:
Please Sign up or sign in to vote.
See more:
This is an SP,when i execute in SMStudio it getting error
Msg 102, Level 15, State 1, Line 7
Incorrect syntax near ')'.



DECLARE @tblPossibleAudits TABLE (auditid int)

SELECT DISTINCT TBL.auditid, AD.auditname
FROM (
SELECT POS.auditid, COUNT(AJ.loanmasterid) as totalloans, COUNT(IMG.loanmasterid) as imgloadedloans
FROM @tblPossibleAudits POS INNER JOIN auditjunction AJ
ON AJ.auditid = POS.auditid LEFT JOIN ldocumentimages IMG)
ON IMG.loanmasterid = AJ.loanmasterid
GROUP BY POS.auditid
)
TBL INNER JOIN auditdescriptions AD
ON AD.auditid = TBL.auditid
WHERE TBL.totalloans > TBL.imgloadedloans
ORDER BY AD.auditname
FOR XML AUTO
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Try this:
SELECT DISTINCT TBL.auditid
			  , AD.auditname
FROM
	(SELECT POS.auditid
		  , count(AJ.loanmasterid) AS totalloans
		  , count(IMG.loanmasterid) AS imgloadedloans
	 FROM
		 @tblPossibleAudits POS
		 INNER JOIN auditjunction AJ
			 ON AJ.auditid = POS.auditid
		 LEFT JOIN ldocumentimages IMG
			 ON IMG.loanmasterid = AJ.loanmasterid
	 GROUP BY
		 POS.auditid
	)
	TBL
	INNER JOIN auditdescriptions AD
		ON AD.auditid = TBL.auditid
WHERE
	TBL.totalloans > TBL.imgloadedloans
ORDER BY
	AD.auditname
FOR XML
	AUTO
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi,

i guess there is an extra ) after IMG.Try removing that.
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

ON AJ.auditid = POS.auditid LEFT JOIN ldocumentimages IMG)

remove ) from this line...

Thanks,
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100