CAST DECIMAL to INT

后端 未结 10 2324
攒了一身酷
攒了一身酷 2020-12-13 01:49

I\'m trying to do this:

SELECT CAST(columnName AS INT), moreColumns, etc
FROM myTable
WHERE ...

I\'ve looked at the help FAQs here: http://

10条回答
  •  一整个雨季
    2020-12-13 02:13

    You could try the FLOOR function like this:

    SELECT FLOOR(columnName), moreColumns, etc 
    FROM myTable 
    WHERE ... 
    

    You could also try the FORMAT function, provided you know the decimal places can be omitted:

    SELECT FORMAT(columnName,0), moreColumns, etc 
    FROM myTable 
    WHERE ... 
    

    You could combine the two functions

    SELECT FORMAT(FLOOR(columnName),0), moreColumns, etc 
    FROM myTable 
    WHERE ... 
    

提交回复
热议问题