SELECT prod_id, quantity, quantity * item_price AS expanded_price FROM orderItems WHERE order_num = 20008
SELECT prod_id, SUM(quantity * item_price) FROM orderItems GROUP BY prod_id HAVING COUNT(*)
SELECT vend_id, COUNT(*) FROM products WHERE prod_price >= 4 GROUP BY vend_id HAVING COUNT(prod_id) >= 2;
SELECT vend_id, COUNT(*) FROM products GROUP BY vend_id HAVING COUNT(prod_id) >= 2 AND vend_id LIKE '%01%';
SELECT vend_id, SUM(prod_price) AS total_price FROM products GROUP BY vend_id;
SELECT order_num, SUM(quantity * item_price) FROM orderItems GROUP BY order_num HAVING COUNT(order_item) >= 3;
SELECT vend_id FROM products WHERE prod_name = 'King Doll';
SELECT vend_name, vend_address FROM vendors WHERE vend_id = 'FNG01';
SELECT vend_name, vend_address FROM vendors WHERE vend_id IN (SELECT vend_id FROM products WHERE prod_name = 'King Doll');
SELECT vend_name, vend_address FROM vendors, products;
SELECT vend_name, vend_address FROM vendors v, products p WHERE v.vend_id = p.vend_id AND prod_name = 'King Doll';
SELECT vend_name, vend_address FROM vendors v INNER JOIN products p ON v.vend_id = p.vend_id WHERE prod_name = 'King Doll';
SELECT vend_name, vend_address FROM vendors NATURAL JOIN products WHERE prod_name = 'King Doll';
SELECT cust_name, cust_contact FROM customers WHERE cust_id IN (
SELECT cust_id FROM orders WHERE order_num IN (
SELECT order_num FROM orderItems WHERE prod_id = 'RGAN01'
)
);
SELECT cust_name, cust_contact
FROM orderItems NATURAL JOIN orders NATURAL JOIN customers
WHERE prod_id = 'RGAN01';
SELECT cust_name, cust_contact
FROM orderItems ois INNER JOIN orders os INNER JOIN customers cs
ON ois.order_num = os.order_num AND os.cust_id = cs.cust_id
WHERE prod_id = 'RGAN01';
SELECT cust_name, cust_contact
FROM orderItems ois, orders os, customers cs
WHERE ois.order_num = os.order_num
AND
os.cust_id = cs.cust_id
AND
prod_id = 'RGAN01';