当前位置: 代码迷 >> Sql Server >> 求个查询话语ing.
  详细解决方案

求个查询话语ing.

热度:76   发布时间:2016-04-27 11:01:25.0
求个查询语句ing...
表mxls,字段ml、je,数据类型decimal(14, 2)
一条语句既能ml/je之间的值,又能查询ml/je大于等于0.05、或者是小于等于0.05
select * from mxls 
where ml/je >= 1
and ml/je <= 0.05

或者

select * from mxls 
where ml/je >= 空
and ml/je <= 0.05

------解决方案--------------------
SQL code
--你要查询既大于0.05又要小于0.05的,那不是全部记录了?select *,ml/je from mxls  where ml/je >= 0.05or ml/je <= 0.05
------解决方案--------------------
如果是全部记录直接
select *,ml/je from mxls 
不需要条件了

select *,(ml/je) aa, (case when (ml/je)>0.5 then 'big' else 'small' end )as bb from tmxls
------解决方案--------------------
?--你要查询既大于0.05又要小于0.05的,那不是全部记录了?
是不是要个动态语句?
还是问题描述少了细节信息?

------解决方案--------------------
SQL code
Create proc text_p(  @sWhere varchar(100))asbegin  declare @sSql varchar(1000)  set @sSql = 'select * from mxls where '+ @sWhere  exec (@sSql)end
------解决方案--------------------
SQL code
select * from mxls  where ml/je >= 1and ml/je <= 0.05-->你这个查的不就是ml/je=0.5的记录?-->6#create proc test(  @Where varchar(100))asbegin  declare @sql varchar(500)  set @Sql = 'select * from mxls where '+ @Where  exec (@Sql)end-->调用exec test 'ml/je >= 0.05'--orexec test 'ml/je <= 0.05'
  相关解决方案