从数据类型 varchar 转换为 numeric 时出错
book05 是decimal(10, 2)
sql语句报错:从数据类型 varchar 转换为 numeric 时出错。
selectbook05=case when book05 is null or book05='' then '('+ltrim(str(count(*)))+')' else ltrim(str(book05)) + '('+ltrim(str(count(*)))+')' end from booksgroup by book05 order by book05
selectbook05=case when book05 is null or book05='' --这里出错,book05是数字类型,不能这样then '('+ltrim(str(count(*)))+')' else ltrim(str(book05)) + '('+ltrim(str(count(*)))+')' end from booksgroup by book05 order by book05selectbook05=case when book05 is null--这么就行了then '('+ltrim(str(count(*)))+')' else ltrim(str(book05)) + '('+ltrim(str(count(*)))+')' end from booksgroup by book05 order by book05
[解决办法]
selectbook05=case when isnull(book05,0)=0 then '('+ltrim(str(count(*)))+')' else ltrim(str(book05)) + '('+ltrim(str(count(*)))+')' end from booksgroup by book05 order by book05
[解决办法]
selectbook05=case when book05 is null or book05='' then '('+ltrim(count(*))+')' else ltrim(book05) + '('+ltrim(count(*))+')' end from booksgroup by book05order by book05