WITH wrk as (SELECT * FROM emp), boss as (SELECT * FROM emp) SELECT DISTINCT (deptname) FROM dept
WHERE deptname NOT IN
(SELECT wrk.deptname FROM wrk JOIN boss
ON wrk.bossno = boss.empno
WHERE wrk.empsalary > boss.empsalary);
empfname |
---|
Andrew |
Clare |
Nancy |
Sarah |
SELECT deptname, AVG(empsalary) FROM emp GROUP BY deptname HAVING AVG(empsalary) > 25000;
deptname | expr1001 |
---|---|
Purchasing | $56,000.00 |
WITH wrk as (SELECT * FROM emp), boss as (SELECT * FROM emp) SELECT wrk.empfname, boss.empfname
FROM wrk JOIN boss
ON wrk.bossno = boss.empno
WHERE wrk.deptname = 'Marketing'
AND wrk.empsalary > 25000;
SELECT monname, monnum FROM monarch WHERE premonname = 'Victoria' AND premonnum = 'I';
monname | monnum |
---|---|
Edward | VII |
SELECT COUNT(montype) FROM monarch WHERE montype = 'King';
SELECT COUNT(*) FROM product JOIN assembly
ON product.prodid = assembly.prodid
WHERE proddesc = 'Animal photography kit';
SELECT SUM(PRODCOST*quantity) AS 'Total cost' FROM product JOIN assembly
ON product.prodid = assembly.subprodid
WHERE product.prodid IN
(SELECT subprodid FROM product JOIN assembly
ON product.prodid = assembly.prodid
WHERE proddesc = 'Animal photography kit');
This page is part of the promotional and support material for Data Management (open edition) by Richard T. Watson |