为什么嵌套转换在 MySQL 中不起作用?(它确实使用 SQL Server)
select cast(cast(myColumn as decimal(5,2)) as int) from myTable
为什么嵌套转换在 MySQL 中不起作用?(它确实使用 SQL Server)
select cast(cast(myColumn as decimal(5,2)) as int) from myTable
根据手册:
CAST(expr AS type)
[...]
CONVERT(expr,type)
[...]
type
可以是以下值之一:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
因此,只需按照手册进行操作:
SELECT CAST(CAST(myColumn AS DECIMAL(5,2)) AS SIGNED) FROM myTable
或者
SELECT CAST(CAST(myColumn AS DECIMAL(5,2)) AS UNSIGNED) FROM myTable
此查询正在处理嵌套转换的概念。
cast(sum(cast(Column_name int)+ cast(Column_name as int)) as bigint) 作为来自 table_name 的付款