我有一个名为T5VAULTSL3
的表格,我的客户位于VL3CLIENTNUM
列标题下,其现金金额低于VL3CONSIDERATION
;
VL3CONSIDERATION
将对象资源管理器显示为(char(20), null)
我想要实现的是将所有'Unique'
个客户编号分组,其中合并现金(consideration) is > 10000
我试过了;
SELECT vl3clientnum, CAST(VL3CONSIDERATION AS NUMERIC (20,2))
FROM T5VAULTSL3
WHERE Vl3CONSIDERATION > 10000
返回
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value ' 0.00' to data type int.
所以我试过
SELECT vl3clientnum, VL3CONSIDERATION
FROM T5VAULTSL3
WHERE CAST (Vl3CONSIDERATION AS NUMERIC (20,2)) > 10000
返回
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
和
SELECT vl3clientnum, CAST (VL3CONSIDERATION AS NUMERIC (20,2)) AS CONSIDERATION
FROM T5VAULTSL3
WHERE CAST (Vl3CONSIDERATION AS NUMERIC (20,2)) > 10000
返回
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
我是否必须使用'声明'功能,如果是,如何使用?有点难过这个......
其他尝试包括。
SELECT vl3clientnum, CAST (VL3CONSIDERATION AS NUMERIC (20,2))
FROM T5VAULTSL3
WHERE VL3CONSIDERATION > 10000
GROUP BY VL3CLIENTNUM, vl3consideration
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value ' 0.00' to data type int.
SELECT vl3clientnum, VL3CONSIDERATION
FROM T5VAULTSL3
WHERE CAST (VL3CONSIDERATION as NUMERIC(20,2)) > 10000
GROUP BY VL3CLIENTNUM, vl3consideration
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
绝对困惑!!!!
答案 0 :(得分:1)
我猜原因是'0.00'中有空格。你最好修剪空间:
CAST(LTRIM(RTRIM(VL3CONSIDERATION)) AS NUMERIC (20,2))