SELECT
Pname,
Dname,
COUNT(WO.Essn),
SUM(WO.Hours)
FROM
PROJECT AS P,
WORKS_ON AS WO,
DEPARTMENT AS D
WHERE
P.Dnum = D.Dnumber
AND P.Pnumber = WO.Pno
GROUP_BY Pno
HAVING
COUNT(WO.Essn) > 1;
I am getting
in query expression. (Error 3075)
error with this code. What should I change
you're group by
statement is not correct:
SELECT
Pname,
Dname,
COUNT(WO.Essn),
SUM(WO.Hours)
FROM
PROJECT AS P,
WORKS_ON AS WO,
DEPARTMENT AS D
WHERE
P.Dnum = D.Dnumber
AND P.Pnumber = WO.Pno
GROUP BY
Pname,
Dname
HAVING
COUNT(WO.Essn) > 1;
Learn to use proper JOIN
syntax. In MS Access, this looks like:
SELECT P.Pname, D.Dname,
COUNT(WO.Essn), SUM(WO.Hours)
FROM (PROJECT AS P INNER JOIN
WORKS_ON AS WO
ON P.Pnumber = WO.Pno
) INNER JOIN
DEPARTMENT AS D
ON P.Dnum = D.Dnumber
GROUP_BY P.Pname, D.Dname
HAVING COUNT(WO.Essn) > 1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.