sql语句提示"LEFT": syntax error!大家帮忙看看
SELECT PROJ.PROJECTID, COUNT(*) AS COUNT ,D.NUMBER AS NUMBER FROM PROJECTEQUIPMENT_V1 PROJ GROUP BY PROJECTID
LEFT JOIN(SELECT PROJE.PROJECTID, COUNT(*) AS NUMBER FROM PROJECTEMPLOYEE_V1 PROJE GROUP BY PROJECTID) D
ON PROJ.PROJECTID=D.PROJECTID
[Err] 1 - near "LEFT": syntax error
哪位大侠帮看看,是哪出了问题,谢谢!!!
[解决办法]
要么把第一个Group By去掉,如果要用Group By的话可以做成Subquery跟下面的一样,这样就不会错了。
[解决办法]
--楼主写的语法不对。参考如下:
SELECT
a.PROJECTID,A.[COUNT],D.[NUMBER]
FROM
(
SELECT
PROJ.PROJECTID,
COUNT(*) AS COUNT
FROM PROJECTEQUIPMENT_V1 PROJ
GROUP BY PROJECTID
) A
LEFT JOIN
(
SELECT PROJE.PROJECTID, COUNT(*) AS NUMBER
FROM PROJECTEMPLOYEE_V1 PROJE
GROUP BY PROJECTID
) D
ON A.PROJECTID=D.PROJECTID