标签:
CREATE TABLE CANDY_TBL SELECT * FROM PRODUCTS_TBL; INSERT INTO CANDY_TBL VALUES ( ‘9‘, ‘CANDY CORN‘, 1.35 ); SELECT * FROM CANDY_TBL; +---------+-------------------------+-------+ | PROD_ID | PROD_DESC | COST | +---------+-------------------------+-------+ | 11235 | WITCH COSTUME | 29.99 | | 119 | ASSORTED MASKS | 4.95 | | 13 | FALSE PARAFFIN TEETH | 1.10 | | 15 | ASSORTED COSTUMES | 10.00 | | 222 | PLASTIC PUMPKIN 18 INCH | 7.75 | | 6 | PUMPKIN CANDY | 1.45 | | 87 | PLASTIC SPIDERS | 1.05 | | 9 | CANDY CORN | 1.35 | | 90 | LIGHTED LANTERNS | 14.50 | | 9 | CANDY CORN | 1.35 | +---------+-------------------------+-------+ SELECT DISTINCT (PROD_DESC) FROM CANDY_TBL; +-------------------------+ | PROD_DESC | +-------------------------+ | WITCH COSTUME | | ASSORTED MASKS | | FALSE PARAFFIN TEETH | | ASSORTED COSTUMES | | PLASTIC PUMPKIN 18 INCH | | PUMPKIN CANDY | | PLASTIC SPIDERS | | CANDY CORN | | LIGHTED LANTERNS | +-------------------------+
SELECT * FROM PRODUCTS_TBL WHERE COST < 5; +---------+----------------------+------+ | PROD_ID | PROD_DESC | COST | +---------+----------------------+------+ | 119 | ASSORTED MASKS | 4.95 | | 13 | FALSE PARAFFIN TEETH | 1.10 | | 6 | PUMPKIN CANDY | 1.45 | | 87 | PLASTIC SPIDERS | 1.05 | | 9 | CANDY CORN | 1.35 | +---------+----------------------+------+
SELECT * FROM PRODUCTS_TBL; +---------+-------------------------+-------+ | PROD_ID | PROD_DESC | COST | +---------+-------------------------+-------+ | 11235 | WITCH COSTUME | 29.99 | | 119 | ASSORTED MASKS | 4.95 | | 13 | FALSE PARAFFIN TEETH | 1.10 | | 15 | ASSORTED COSTUMES | 10.00 | | 222 | PLASTIC PUMPKIN 18 INCH | 7.75 | | 6 | PUMPKIN CANDY | 1.45 | | 87 | PLASTIC SPIDERS | 1.05 | | 9 | CANDY CORN | 1.35 | | 90 | LIGHTED LANTERNS | 14.50 | +---------+-------------------------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY PROD_DESC ASC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | ASSORTED COSTUMES | 15 | 10.00 | | ASSORTED MASKS | 119 | 4.95 | | CANDY CORN | 9 | 1.35 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | LIGHTED LANTERNS | 90 | 14.50 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | PLASTIC SPIDERS | 87 | 1.05 | | PUMPKIN CANDY | 6 | 1.45 | +-------------------------+---------+-------+ SELECT * FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY PROD_DESC ASC; +---------+-------------------------+-------+ | PROD_ID | PROD_DESC | COST | +---------+-------------------------+-------+ | 15 | ASSORTED COSTUMES | 10.00 | | 119 | ASSORTED MASKS | 4.95 | | 9 | CANDY CORN | 1.35 | | 13 | FALSE PARAFFIN TEETH | 1.10 | | 90 | LIGHTED LANTERNS | 14.50 | | 222 | PLASTIC PUMPKIN 18 INCH | 7.75 | | 87 | PLASTIC SPIDERS | 1.05 | | 6 | PUMPKIN CANDY | 1.45 | +---------+-------------------------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY PROD_DESC DESC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | PUMPKIN CANDY | 6 | 1.45 | | PLASTIC SPIDERS | 87 | 1.05 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | LIGHTED LANTERNS | 90 | 14.50 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | CANDY CORN | 9 | 1.35 | | ASSORTED MASKS | 119 | 4.95 | | ASSORTED COSTUMES | 15 | 10.00 | +-------------------------+---------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY PROD_DESC,PROD_ID,COST ASC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | ASSORTED COSTUMES | 15 | 10.00 | | ASSORTED MASKS | 119 | 4.95 | | CANDY CORN | 9 | 1.35 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | LIGHTED LANTERNS | 90 | 14.50 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | PLASTIC SPIDERS | 87 | 1.05 | | PUMPKIN CANDY | 6 | 1.45 | +-------------------------+---------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY COST,PROD_DESC,PROD_ID ASC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | PLASTIC SPIDERS | 87 | 1.05 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | CANDY CORN | 9 | 1.35 | | PUMPKIN CANDY | 6 | 1.45 | | ASSORTED MASKS | 119 | 4.95 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | ASSORTED COSTUMES | 15 | 10.00 | | LIGHTED LANTERNS | 90 | 14.50 | +-------------------------+---------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY PROD_ID,COST,PROD_DESC ASC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | ASSORTED MASKS | 119 | 4.95 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | ASSORTED COSTUMES | 15 | 10.00 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | PUMPKIN CANDY | 6 | 1.45 | | PLASTIC SPIDERS | 87 | 1.05 | | CANDY CORN | 9 | 1.35 | | LIGHTED LANTERNS | 90 | 14.50 | +-------------------------+---------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY 3,2,1 DESC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | PLASTIC SPIDERS | 87 | 1.05 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | CANDY CORN | 9 | 1.35 | | PUMPKIN CANDY | 6 | 1.45 | | ASSORTED MASKS | 119 | 4.95 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | ASSORTED COSTUMES | 15 | 10.00 | | LIGHTED LANTERNS | 90 | 14.50 | +-------------------------+---------+-------+ SELECT PROD_DESC, PROD_ID, COST FROM PRODUCTS_TBL WHERE COST < 20 ORDER BY 1,2,3 DESC; +-------------------------+---------+-------+ | PROD_DESC | PROD_ID | COST | +-------------------------+---------+-------+ | ASSORTED COSTUMES | 15 | 10.00 | | ASSORTED MASKS | 119 | 4.95 | | CANDY CORN | 9 | 1.35 | | FALSE PARAFFIN TEETH | 13 | 1.10 | | LIGHTED LANTERNS | 90 | 14.50 | | PLASTIC PUMPKIN 18 INCH | 222 | 7.75 | | PLASTIC SPIDERS | 87 | 1.05 | | PUMPKIN CANDY | 6 | 1.45 | +-------------------------+---------+-------+
SELECT COUNT(*) FROM PRODUCTS_TBL; +----------+ | COUNT(*) | +----------+ | 9 | +----------+ SELECT COUNT(PROD_ID) FROM PRODUCTS_TBL; +----------------+ | COUNT(PROD_ID) | +----------------+ | 9 | +----------------+ SELECT STATE FROM EMPLOYEE_TBL; +-------+ | STATE | +-------+ | IN | | IN | | IN | | IN | | IN | | IN | +-------+ SELECT COUNT(DISTINCT STATE) FROM EMPLOYEE_TBL; +-----------------------+ | COUNT(DISTINCT STATE) | +-----------------------+ | 1 | +-----------------------+
SELECT PROD_DESC PD FROM PRODUCTS_TBL; +-------------------------+ | PD | +-------------------------+ | WITCH COSTUME | | ASSORTED MASKS | | FALSE PARAFFIN TEETH | | ASSORTED COSTUMES | | PLASTIC PUMPKIN 18 INCH | | PUMPKIN CANDY | | PLASTIC SPIDERS | | CANDY CORN | | LIGHTED LANTERNS | +-------------------------+ SELECT PROD_DESC, PROD_DESC PD FROM PRODUCTS_TBL; +-------------------------+-------------------------+ | PROD_DESC | PD | +-------------------------+-------------------------+ | WITCH COSTUME | WITCH COSTUME | | ASSORTED MASKS | ASSORTED MASKS | | FALSE PARAFFIN TEETH | FALSE PARAFFIN TEETH | | ASSORTED COSTUMES | ASSORTED COSTUMES | | PLASTIC PUMPKIN 18 INCH | PLASTIC PUMPKIN 18 INCH | | PUMPKIN CANDY | PUMPKIN CANDY | | PLASTIC SPIDERS | PLASTIC SPIDERS | | CANDY CORN | CANDY CORN | | LIGHTED LANTERNS | LIGHTED LANTERNS | +-------------------------+-------------------------+
SELECT EMP_ID SSN, LAST_NAME FROM EMPLOYEE_TBL WHERE EMP_ID = ‘213764555‘ ORDER BY 1; +-----------+-----------+ | SSN | LAST_NAME | +-----------+-----------+ | 213764555 | GLASS | +-----------+-----------+ SELECT EMP_ID SSN, LAST_NAME FROM EMPLOYEE_TBL ORDER BY 1; +-----------+-----------+ | SSN | LAST_NAME | +-----------+-----------+ | 213764555 | GLASS | | 220984332 | WALLACE | | 311549902 | STEPHENS | | 313782439 | GLASS | | 442346889 | PLEW | | 443679012 | SPURGEON | +-----------+-----------+
SELECT PROD_DESC, COST FROM PRODUCTS_TBL ORDER BY COST DESC; +-------------------------+-------+ | PROD_DESC | COST | +-------------------------+-------+ | WITCH COSTUME | 29.99 | | LIGHTED LANTERNS | 14.50 | | ASSORTED COSTUMES | 10.00 | | PLASTIC PUMPKIN 18 INCH | 7.75 | | ASSORTED MASKS | 4.95 | | PUMPKIN CANDY | 1.45 | | CANDY CORN | 1.35 | | FALSE PARAFFIN TEETH | 1.10 | | PLASTIC SPIDERS | 1.05 | +-------------------------+-------+ SELECT CUST_NAME, CUST_PHONE FROM CUSTOMER_TBL WHERE CUST_NAME = ‘WENDY WOLF‘; +------------+------------+ | CUST_NAME | CUST_PHONE | +------------+------------+ | WENDY WOLF | 3172913421 | +------------+------------+
标签:
原文地址:http://www.cnblogs.com/fatoland/p/4539677.html