case when 问题

donghu653 2009-06-22 10:12:53
sql语句:
(case when b.mjl>0 then (case when a.sl%b.mjl<>0 then '*' else '' end) else '' end) as 标志
a.sl、b.mjl 为int型
错误提示:
服务器: 消息 8117,级别 16,状态 1,行 1
操作数数据类型 numeric 无效(运算符 modulo)。

要想按以上语句要求输出需要怎样修改?谢谢!
...全文
23 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxmcxm 2009-06-22
  • 打赏
  • 举报
回复
出来这样的提示,说明a.sl,b.mjl中至少有一字段不是int,
可先转为int
a.sl%b.mjl 改为convert(int,a.sl)%convert(int,b.mjl)

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧