在SQL中,TRUNC()
函數(shù)可以用來截斷數(shù)字到指定的位數(shù)。如果你想將數(shù)字截斷為整數(shù)位,可以使用以下方法:
對于Oracle數(shù)據(jù)庫,使用TRUNC()
函數(shù):
SELECT TRUNC(your_number) AS truncated_number
FROM your_table;
對于MySQL數(shù)據(jù)庫,使用FLOOR()
函數(shù)和負數(shù)作為第二個參數(shù):
SELECT FLOOR(your_number * 100) / 100 AS truncated_number
FROM your_table;
對于PostgreSQL數(shù)據(jù)庫,使用TRUNC()
函數(shù):
SELECT TRUNC(your_number)::integer AS truncated_number
FROM your_table;