我想求出'椴木地板'和'柞木地板'的平均材积,如果椴木地板平均材积比柞木地板平均材积多50% 显示高
如果椴木地板平均材积和柞木地板平均材积比率在1.5~0.8之间 显示中
其它 显示低我的代码如下.select d1=avg(材积) from baohao where zhipin='椴木地板'select z1=avg(材积) from baohao where zhipin='柞木地板'case d1/z1 when d1/z1>0.5 then print '高'
when d1/z1>0.8 and d1/z1<1.5 then print '中'
when d1/z1>1.5 then print '低'
end可是不能执行..大家来帮忙~~~
如果椴木地板平均材积和柞木地板平均材积比率在1.5~0.8之间 显示中
其它 显示低我的代码如下.select d1=avg(材积) from baohao where zhipin='椴木地板'select z1=avg(材积) from baohao where zhipin='柞木地板'case d1/z1 when d1/z1>0.5 then print '高'
when d1/z1>0.8 and d1/z1<1.5 then print '中'
when d1/z1>1.5 then print '低'
end可是不能执行..大家来帮忙~~~
解决方案 »
- SQL基础题
- 批量写入数据的问题
- 急啊,请问更新锁变为排他锁是在更新完成时变的,还是更新前变的
- 帮忙解读一下一个包含Inner join 和 left outer join的SQL语句
- ADO查询两次变成很慢(假死状态)
- 可以把一个库中的某个表转移到另一个库中吗?
- 更新出错!UPDATE TABLE1 set Field2=substring(field1,1,30) 出错了!
- 这条语句怎么定?
- SQL2000DTS问题,急!!!!!!!!!!!!!!在线等待
- 怎样让远程SQL数据库停止和启动啊。谢谢
- 急! ! ! ! 急! ! ! ! 急! ! ! ! 提取表中头10条,头11-20,21-30条,31-40条数据按id降序
- 记录误删!救命
case
when d1/z1>=0.5 then '高'
when d1/z1>0.8 and d1/z1<1.5 then '中'
when d1/z1>1.5 then '低'
else ''
end
(
材积 numeric(10,1),
zhipin varchar(20)
)
insert baohao
select 2.0,'椴木地板' union all
select 1.0,'椴木地板' union all
select 0.4,'椴木地板' union all
select 2.0,'柞木地板' union all
select 1.0,'柞木地板'
select * from baohaoselect d1=avg(材积),zhipin into #T from baohao group by zhipin
select case
when (select d1 from #t where zhipin='椴木地板')/(select d1 from #t where zhipin='柞木地板')>0.5 then '高'
end
其他的自己加上,说实在的,还不是太明白你需求。
你把你要的结果用表格的形式说一下啊-_-
hjw01592(风男) ( ) 信誉:100 2006-08-22 16:54:00 得分: 0
楼上,楼主意思是要根据比率分类啊
上面的不对吗?
(
材积 numeric(10,1),
zhipin varchar(20)
)
insert baohao
select 2.0,'椴木地板' union all
select 1.0,'椴木地板' union all
select 0.4,'椴木地板' union all
select 2.0,'柞木地板' union all
select 1.0,'柞木地板'
select * from baohaodeclare @a numeric(10,1),
@b numeric(10,1)
select @a=avg(材积) from baohao where zhipin='椴木地板'
select @b=avg(材积) from baohao where zhipin='柞木地板'
select case when @a/@b>=1.5 then '低'
when @a/@b>=0.8 and @a/@b<1.5 then '中'
else '低' end
自己看着改改吧 ^_^
when @d1/@z1>0.8 and @d1/@z1<1.5 then '中'
when @d1/@z1>1.5 then '低'
else '低'
end