标签:
SELECT EMP_ID, CAST(EMP_ID AS UNSIGNED) FROM EMPLOYEE_TBL; +-----------+--------------------------+ | EMP_ID | CAST(EMP_ID AS UNSIGNED) | +-----------+--------------------------+ | 213764555 | 213764555 | | 220984332 | 220984332 | | 311549902 | 311549902 | | 313782439 | 313782439 | | 442346889 | 442346889 | | 443679012 | 443679012 | +-----------+--------------------------+ SELECT PAY_RATE, CAST(PAY_RATE AS CHAR) -> FROM EMPLOYEE_PAY_TBL; +----------+------------------------+ | PAY_RATE | CAST(PAY_RATE AS CHAR) | +----------+------------------------+ | NULL | NULL | | 11.00 | 11.00 | | NULL | NULL | | NULL | NULL | | 14.75 | 14.75 | | 15.00 | 15.00 | +----------+------------------------+ SELECT PAY_RATE, CAST(PAY_RATE AS CHAR) FROM EMPLOYEE_PAY_TBL WHERE PAY_RATE IS NOT NULL; +----------+------------------------+ | PAY_RATE | CAST(PAY_RATE AS CHAR) | +----------+------------------------+ | 11.00 | 11.00 | | 14.75 | 14.75 | | 15.00 | 15.00 | +----------+------------------------+ SELECT LAST_NAME, FIRST_NAME, EMP_ID FROM EMPLOYEE_TBL ORDER BY EMP_ID; +-----------+------------+-----------+ | LAST_NAME | FIRST_NAME | EMP_ID | +-----------+------------+-----------+ | GLASS | RBANDON | 213764555 | | WALLACE | MARIAH | 220984332 | | STEPHENS | TINA | 311549902 | | GLASS | JACOB | 313782439 | | PLEW | LINDA | 442346889 | | SPURGEON | TIFFANY | 443679012 | +-----------+------------+-----------+ SELECT CONCAT(LAST_NAME, ‘, ‘, FIRST_NAME) AS NAME, CONCAT(SUBSTR(EMP_ID, 1, 3), ‘-‘, SUBSTR(EMP_ID, 4, 2), ‘-‘, SUBSTR(EMP_ID, 6, 4)) AS ID FROM EMPLOYEE_TBL ORDER BY ID; +-------------------+-------------+ | NAME | ID | +-------------------+-------------+ | GLASS, RBANDON | 213-76-4555 | | WALLACE, MARIAH | 220-98-4332 | | STEPHENS, TINA | 311-54-9902 | | GLASS, JACOB | 313-78-2439 | | PLEW, LINDA | 442-34-6889 | | SPURGEON, TIFFANY | 443-67-9012 | +-------------------+-------------+ SELECT CONCAT(LAST_NAME, ‘, ‘, FIRST_NAME) AS NAME, CONCAT(SUBSTR(EMP_ID, 1, 3), ‘-‘, SUBSTR(EMP_ID, 4, 2), ‘-‘, SUBSTR(EMP_ID, 6, 4)) AS ID FROM EMPLOYEE_TBL ORDER BY 1; +-------------------+-------------+ | NAME | ID | +-------------------+-------------+ | GLASS, JACOB | 313-78-2439 | | GLASS, RBANDON | 213-76-4555 | | PLEW, LINDA | 442-34-6889 | | SPURGEON, TIFFANY | 443-67-9012 | | STEPHENS, TINA | 311-54-9902 | | WALLACE, MARIAH | 220-98-4332 | +-------------------+-------------+
标签:
原文地址:http://www.cnblogs.com/fatoland/p/4542385.html