我试图删除CallAmt下面$51中的所有值。
当我运行下面的查询时,收到一条错误消息8114
我想我需要以某种方式将CallAmt (varchar)转换为十进制并删除'$'。
有什么想法吗?

Select AccountName, AccountNumber, CallType, CallAmt, TradeDate, DueDate,
CASE
    WHEN CallType = 'RM' THEN 'H'
    WHEN CallType = 'CM' THEN 'H'
    WHEN CallType = 'RT' THEN 'F'
END as CallType

from dbo.EXT250

Where CallType in ('RM', 'CM', 'MD', 'RT') and AccountNumber Not Like '[29]%' and CallAmt > 50.00

最佳答案

您可以尝试:

Select AccountName, AccountNumber, CallType, CallAmt, TradeDate, DueDate,
       (CASE WHEN CallType = 'RM' THEN 'H'
             WHEN CallType = 'CM' THEN 'H'
             WHEN CallType = 'RT' THEN 'F'
        END) as CallType
from dbo.EXT250
Where CallType in ('RM', 'CM', 'MD', 'RT') and
      AccountNumber Not Like '[29]%' and
      cast(replace(CallAmt, '$', '') as decimal(10, 4)) > 50.00;

08-06 17:48