Browse Source

adding examples from PDF

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

156
ZAGI.sql

@ -130,3 +130,159 @@ DROP TABLE vendor;
DROP TABLE region;
DROP TABLE category;
DROP TABLE customer;
-- queries
-- 1
SELECT
SELECT productid, productname, productprice, vendorid, categoryid
FROM product;
-- 1a
SELECT * FROM product;
-- 2
SELECT productname, productid, vendorid, categoryid, productprice
FROM product;
-- 3
SELECT productid,productprice
FROM product;
-- 3a
SELECT productid, productprice, productprice * 1.1
FROM product;
-- 4
SELECT productid, productname, vendorid, productprice
FROM product;
WHERE productprice > 100;
-- 5
SELECT productid, productname, vendorid, productprice
FROM product;
WHERE productprice <= 100 AND categoryid = 'FW';
-- 6
SELECT vendorid
FROM product;
-- 7
SELECT DISTINCT vendorid
FROM product;
-- 8
SELECT productid, productname, categoryid, productprice
FROM product;
WHERE categoryid = 'FW'
ORDER BY productprice;
-- 9
SELECT productid, productname, categoryid, productprice
FROM product;
WHERE categoryid = 'FW'
ORDER BY productprice DESC;
-- 10
SELECT productid, productname, categoryid, productprice
FROM product;
ORDER BY categoryid, price;
-- 11
SELECT *
FROM product;
WHERE productname LIKE '%Boot%';
-- 12
SELECT AVG(productprice)
FROM product;
-- 13
SELECT COUNT(*)
FROM product;
-- 14
SELECT COUNT(DISTINCT vendorid)
FROM product;
-- 15
SELECT COUNT(*), AVG(productprice), MIN(productprice), MAX(productprice)
FROM product
WHERE categoryid = 'CP';
-- 16
SELECT vendorid, COUNT(*), AVG(productprice)
FROM product
GROUP BY vendorid;
-- 17
SELECT COUNT(*), AVG(productprice)
FROM product
GROUP BY vendorid;
-- 18
SELECT vendorid, COUNT(*)
FROM product
WHERE productprice >= 100
GROUP BY vendorid;
-- 19
SELECT vendorid, categoryid, COUNT(*), AVG(productprice)
FROM product
GROUP BY vendorid, categoryid;
-- 20
SELECT productd, SUM(noofitems)
FROM soldvia
GROUP BY productid;
-- 21
SELECT productid, COUNT(tid)
FROM soldvia
GROUP BY productid;
-- 22
SELECT vendorid, categoryid, COUNT(*), AVG(productprice)
FROM product
GROUP BY vendorid, categoryid
HAVING COUNT(*) > 1;
-- 23
SELECT vendorid, categoryid, COUNT(*), AVG(productprice)
FROM product
WHERE productprice >= 50
GROUP BY vendorid, categoryid
HAVING COUNT(*) > 1;
-- doot
Loading…
Cancel
Save