1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
SELECT PROD_ID, PROD_CATEGORY, PROD_SUB_CATEGORY FROM PRODUCT;
CREATE TABLE ORDERS ( Order_ID NUMBER(5), Order_Date DATE, Order_Priority VARCHAR2(20), Ord_Id VARCHAR2(10) );
CREATE TABLE ORDERS ( Order_ID NUMBER(5) PRIMARY KEY NOT NULL, Order_Date DATE, Order_Priority VARCHAR2(20), Ord_Id VARCHAR2(10) );
DROP TABLE ORDERS;
INSERT INTO PRODUCT (Prod_id, Prod_Category, Prod_Sub_Category) VALUES ('Prod_1', 'OFFICE SUPPLIES', 'STORAGE & ORGANIZATION');
INSERT INTO PRODUCT (Prod_id, Prod_Sub_Category, Prod_Category) VALUES ('Prod_1', 'STORAGE & ORGANIZATION', 'OFFICE SUPPLIES');
INSERT INTO PRODUCT VALUES ('Prod_1', 'OFFICE SUPPLIES', 'STORAGE & ORGANIZATION');
UPDATE PRODUCT SET Prod_Sub_Category = 'FURNITURE & LIGHTING' WHERE Prod_id = 'Prod_1';
UPDATE PRODUCT SET Prod_Sub_Category = 'FURNITURE & LIGHTING';
SELECT Prod_id FROM PRODUCT;
SELECT * FROM PRODUCT;
SELECT Mkt_Id, 1.5 * Sales FROM MARKET;
SELECT Mkt_Id, 1.5 * Sales New_Sales FROM MARKET;
SELECT * FROM MARKET WHERE Prod_Id = 'Prod_1' AND Order_Quantity > 30;
SELECT * FROM MARKET WHERE Prod_Id = 'Prod_1' OR Prod_Id = 'Prod_10';
SELECT * FROM MARKET WHERE NOT (Prod_Id = 'Prod_1');
SELECT MIN(Sales) Min_Sales, MAX(Sales) Max_Sales, AVG(Order_Quantity) Avg_Ord_Q, COUNT(*) FROM MARKET WHERE Prod_Id = 'Prod_1';
SELECT * FROM MARKET WHERE Prod_Id = 'Prod_1' AND Order_Quantity > 10 ORDER BY Sales DESC;
SELECT Prod_Id, COUNT(*), AVG(Profit) AVG_Profit FROM MARKET WHERE Order_Quantity > 10 GROUP BY Prod_Id ORDER BY AVG_Profit DESC;
SELECT Prod_Id, COUNT(*), AVG(Profit) AVG_Profit FROM MARKET WHERE Order_Quantity > 10 GROUP BY Prod_Id HAVING COUNT(*) > 5 OR AVG(Profit) > 0 ORDER BY AVG_Profit DESC;
SELECT Prod_Id, AVG(Profit) AVG_Profit FROM MARKET WHERE Order_Quantity > 10 GROUP BY Prod_Id HAVING COUNT(*) > 5 OR AVG(Profit) > 0 ORDER BY AVG_Profit DESC;
SELECT ORDERS.Order_ID, ORDERS.Order_Priority, SHIPPING.Ship_Mode FROM ORDERS JOIN SHIPPING ON ORDERS.Order_ID = SHIPPING.Order_ID WHERE ORDERS.Order_Priority = 'LOW';
SELECT ORDERS.Order_ID, ORDERS.Order_Priority, SHIPPING.Ship_Mode FROM ORDERS JOIN SHIPPING ON ORDERS.Order_ID = SHIPPING.Order_ID;
SELECT ORDERS.Order_ID, ORDERS.Order_Priority, SHIPPING.Ship_Mode FROM ORDERS, SHIPPING WHERE ORDERS.Order_ID = SHIPPING.Order_ID;
|