为什么嵌套转换不能在MySQL中运行? (它使用SQL Server)
select cast(cast(myColumn as decimal(5,2)) as int) from myTable
答案 0 :(得分:3)
根据the manual:
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
答案 1 :(得分:0)
此查询正在研究嵌套转换的概念。
施放(sum(cast(Column_name int)+ cast(Column_name as int))作为bigint)来自table_name的付款