Browse Source

up to example query 35

master
Jared Dunbar 4 years ago
parent
commit
950a888961
Signed by: jared GPG Key ID: CF202CC859BAC692
  1. 100
      ZAGI.sql

100
ZAGI.sql

@ -279,10 +279,108 @@ WHERE productprice >= 50
GROUP BY vendorid, categoryid
HAVING COUNT(*) > 1;
-- 24
SELECT productid, SUM(noofitems)
FROM soldvia
GROUP BY productid;
HAVING SUM(noofitems) > 3;
-- 25
SELECT productid, COUNT(tid)
FROM soldvia
GROUP BY productid
HAVING COUNT(tid) > 1;
-- 26
SELECT productid
FROM soldvia
GROUP BY productid
HAVING SUM(noofitems) > 3;
-- 27
SELECT productid
FROM soldvia
GROUP BY productid
HAVING COUNT(tid) > 1;
-- 28
SELECT productid, productname, productprice
FROM product
WHERE productprice < (
SELECT AVG(productprice)
FROM product
);
-- 29
SELECT productid, productname, productprice
FROM product
WHERE productid IN (
SELECT productid
FROM soldvia
GROUP BY productid
HAVING SUM(noofitems) > 3
);
-- 30
SELECT productid, productname, productprice
FROM productd
WHERE productid IN (
SELECT productid
FROM soldvia
GROUP BY productid
HAVING COUNT(tid) > 1
);
-- 31
SELECT productid, productname, vendorname, productprice
FROM product, vendor
WHERE product.vendorid = vendorid;
-- 31a
SELECT p.productid, p.productname, v.vendorname, p.productprice
FROM product p, vendor v
WHERE p.vendorid = v.vendorid
-- 31b
SELECT p.productid pid, p.productname pname, v.vendorname vname, p.productprice pprice
FROM product p, vendor v
WHERE p.vendorid = v.vendorid;
-- 31c
SELECT p.productid AS pid, p.productname AS pname, v.vendorname AS vname, p.productprice AS pprice
FROM product p, vendor v
WHERE p.vendorid = v.vendorid;
-- 32
SELECT productid, productname, vendorname, productprice
FROM product, vendor
-- 33
SELECT *
FROM product, vendor;
-- 34
SELECT *
FROM product, vendor
WHERE product.vendorid = vendor.vendorid;
-- 35
-- doot
SELECT t.tid, t.tdate, p.productname, sv.noofitems AS quantity, (sv.noofitems * p.productprice) AS amount
FROM product p, salestransaction t, soldvia sv
WHERE sv.productid = p.productid AND sv.tid = t.tid
ORDER BY t.tid;
Loading…
Cancel
Save