CAST to DECIMAL in MySQL

后端 未结 5 577
甜味超标
甜味超标 2020-12-23 12:08

I am trying to cast to Decimal in MySQL like this:

CAST((COUNT(*) * 1.5) AS DECIMAL(2))

I\'m trying to convert the number of rows in a tabl

5条回答
  •  情歌与酒
    2020-12-23 12:21

    DECIMAL has two parts: Precision and Scale. So part of your query will look like this:

    CAST((COUNT(*) * 1.5) AS DECIMAL(8,2))
    

    Precision represents the number of significant digits that are stored for values.
    Scale represents the number of digits that can be stored following the decimal point.

提交回复
热议问题