SELECT ROUND(column_name, decimals) FROM table_name;
decimals用來設定要四捨五入到小數點第幾位,0表示個位數。
範例1:
SELECT ROUND(Price, 0) FROM orders;
範例2:
ROUND(125.315) would return 125
ROUND(125.315, 0) would return 125
ROUND(125.315, 1) would return 125.3
ROUND(125.315, 2) would return 125.32
ROUND(125.315, 3) would return 125.315
ROUND(-125.315, 2) would return -125.32
沒有留言:
張貼留言