Please write the queries base on the above database 2. List ID for all products,
ID: 3573867 • Letter: P
Question
Please write the queries base on the above database
2. List ID for all products, which have NOT been ordered since 28-OCT-2008. Sort your results by
product_id in ascending order. Use Minus for this query
3. List ID for all Arizona customers, who have placed order(s) since 28-OCT-2008. Sort your
results by cust_id in ascending order. Use Intersect for this query
Explanation / Answer
2)
SELECT PRODUCT_ID FROM product
MINUS
SELECT PRODUCT_ID FROM orderline
NATURAL JOIN
ordertable
WHERE
ORDER_DATE > '24-OCT-08'
ORDER BY PRODUCT_ID DESC;
3)
SELECT cust_id FROM customer
WHERE state = ‘AZ’
INTERSECT
SELECT cust_id FROM ordertable WHERE order_date >’28-OCT=2008’
ORDER BY cust_id;