帮帮忙 拜托

diandianfei 2004-04-09 07:39:42
编写一段程序,将每种玩具的价格提高¥0.5,直到玩具的平均价格接近$24.5为止。此外,任何玩具的最大价格不应超过$53。
要用存储过程
...全文
98 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaurence 2004-04-11
  • 打赏
  • 举报
回复
有价值!
diandianfei 2004-04-09
  • 打赏
  • 举报
回复
谢谢大家 太感动了
berylw 2004-04-09
  • 打赏
  • 举报
回复
while(select avg(价格) from 表)<24.5
begin
update 表 set 价格=价格+0.5
if(select max(价格)+0.5 from 表)>53
break
else
continue
end


揭贴吧,完全正确,并且是最简练清晰的
chludlf 2004-04-09
  • 打赏
  • 举报
回复
while (select sum(price)/sum(1) from table )<24.5
begin
update table set price = case when price<53 then price+0.5 else price end

update table set price=49.5 where price>53
end
chludlf 2004-04-09
  • 打赏
  • 举报
回复
while (select sum(price)/sum(1) from table )<24.5
begin
update table set price = case when price<53 then price*1.5 else price end

update table set price=49.5 where price>53
end
zheninchangjiang 2004-04-09
  • 打赏
  • 举报
回复
--按错了,接着
declare @i int
set @i=1
while @i=1
begin
update tablename set price=price+0.5 where price<53-0.5

if cast((select avg(price) from tablename)/0.5 as int)=cast(24.5/0.5 as int)
@i=0
end
zheninchangjiang 2004-04-09
  • 打赏
  • 举报
回复
declare @i int
set @i=1
while @i=1
update tablename set price=price+0.5 where price<53-0.5

34,590

社区成员

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

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