求一查询语句!。。。。。。在线等!

xiaokugong 2006-08-31 08:43:48
表为:
通话次数 通话时长 费用
232 1 45
345 3 56
...................................

现在他们都有数据,现在想UPDATE费用为
通话时长×0.4 ,( 通话时长×0.1)+1.99 这两个哪个少就以哪个算再乘以通话次数做为费用!!!!
...全文
167 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaokugong 2006-08-31
  • 打赏
  • 举报
回复
好了!
xyxfly 2006-08-31
  • 打赏
  • 举报
回复
把你写的贴出来看看

顺便说明一下你各字段类型
xiaokugong 2006-08-31
  • 打赏
  • 举报
回复
将 numeric 转换为数据类型 numeric 时发生算术溢出错误。
语句已终止。
为什么?????
九斤半 2006-08-31
  • 打赏
  • 举报
回复
create table test(cs int,sc int,fy int)
insert test
select 232,1,45 union all
select 345,3,56 union all
select 345,100,56

select * from test

select cs,sc,fy,sc*0.4 as col1,(sc*0.1)+1.99 as col2 from test

begin tran
update test set fy=case when sc*0.4>=(sc*0.1)+1.99 then ((sc*0.1)+1.99)*cs else sc*0.4*cs end
select * from test
rollback tran

drop table test
xyxfly 2006-08-31
  • 打赏
  • 举报
回复
create table test
(
通话次数 int,
通话时长 int,
费用 int
)
insert test
select 232, 1, 45 union all
select 345, 3, 56

select * from test


update test set 费用=(case when 通话时长*0.4 < (通话时长*0.1+1.99) then 通话次数*通话时长*0.4
else 通话次数*(通话时长*0.1+1.99) end)
from test

34,576

社区成员

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

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