请问下拉框控件:拣货量应设置下拉选项为等于0,大于0,应该如何操作?

sql语句:

with a as(select distinct i.sku 物料编码,

               s.descr 物料名称,
                i.id LPN,
                i.qty 数量,
                i.qty - i.qtyallocated - i.qtypicked 可用量,
                i.qtyallocated 分配量,
                i.qtypicked 拣货量,
                case
                  when i.status = 'OK' then
                   '正常'
                  else
                   '冻结'
                end 库存状态,
case
                  when i.status = 'OK' then
                   '合格'
                  when i.status = 'HOLD' and ih.status is not null then
                   to_char(ihc.description)
                  else
                   to_char(ihcloc.description)
                end 冻结状态,

from lotxlocxid i )

select * from where 1=1 ${if(len(kczt)==0,"","and 库存状态=('"+kczt+"')")} ${if(len(jhl)==0,"","and 拣货量=('"+jhl+"')")}

FineReport neyhig 发布于 2020-12-11 09:48
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
朝赟丶Lv6初级互助
发布于2020-12-11 09:51(编辑于 2020-12-11 10:12)

这个,select * from 怎么就直接where了? from的表呢

还有你的题目描述的为等于0,大于0,啥意思?没明白你的需求;

select * from (select a.*, '1' as 参数
 from a
where 大于0
union all
select a.*, '0'
 from a
where 等于0
) t
where 1=1
${if(len(参数)==0,"","and 参数 = ('"+参数+"')")}

然后在控件那里设置,自定义数据字典:实际值 1 --> 显示值 大于0

                                                             实际值0  --> 显示值 等于0

  • 朝赟丶 朝赟丶 回复 neyhig(提问者) ok,已修改回答!
    2020-12-11 10:11 
  • neyhig neyhig(提问者) 回复 朝赟丶 可是这样查询提示:无效的关系运算符?查询不出来了。 大概是这样…因为太多我之前的语句把中间很多省略了。select * from (select a.*,\'1\'as 拣货量 from a where 大于0 union all select a.* ,\'0\'from a where 等于0)t where 1=1 ${if(len(wlbm)==0,\"\",\"and 物料编码 =(\'\"+wlbm+\"\')\")} ${if(len(kczt)==0,\"\",\"and 库存状态 =(\'\"+kczt+\"\')\")} ${if(len(lpn)==0,\"\",\"and LPN =(\'\"+lpn+\"\')\")} ${if(len(dlts)==0,\"\",\"and 天数=(\'\"+dlts+\"\')\")} ${if(len(gys)==0,\"\",\"and 供应商 =(\'\"+gys+\"\')\")} ${if(len(kw)==0,\"\",\"and 库位 =(\'\"+kw+\"\')\")} ${if(len(ywy)==0,\"\",\"and 业务员=(\'\"+ywy+\"\')\")} ${if(len(qy)==0,\"\",\"and 区域 =(\'\"+qy+\"\')\")} ${if(len(wlpc)==0,\"\",\"and 批次号 =(\'\"+wlpc+\"\')\")} ${if(len(wlz)==0,\"\",\"and 物料组 =(\'\"+wlz+\"\')\")} ${if(len(cgy)==0,\"\",\"and 仓管员 =(\'\"+cgy+\"\')\")} ${if(len(jhl)==0,\"\",\"and 拣货量 =(\'\"+jhl+\"\')\")}
    2020-12-11 10:30 
  • 朝赟丶 朝赟丶 回复 neyhig(提问者) 是不是有空格或者哪里少写了个符号,我这里只能看说你语法上没问题,但是不知道你那边具体的环境,要自己排查下了。
    2020-12-11 10:41 
  • 朝赟丶 朝赟丶 回复 neyhig(提问者) 你这里大于0你不会是直接原样这样写的”where 大于0“吧???
    2020-12-11 10:43 
  • neyhig neyhig(提问者) 回复 朝赟丶 没有没有改了改了,select * from (select a.*,\'1\'as 拣货量 from a where 拣货量>0 union all select a.* ,\'0\'as from a where 拣货量=0)t where 1=1…这样您看有错嘛?提示未明确定义列
    2020-12-11 10:52 
最佳回答
0
huyajunLv6初级互助
发布于2020-12-11 09:53

 ${if(len(参数)==0,"","and case  when 拣货量>0 then '大于0'  when 拣货量=0 then '等于0'  else '小于0' end

=('"+参数+"')")}

  • neyhig neyhig(提问者) 为什么这样查询之后显示数据集配置错误?
    2020-12-11 10:06 
  • huyajun huyajun 回复 neyhig(提问者) with a as(select distinct i.sku 物料编码, s.descr 物料名称, i.id LPN, i.qty 数量, i.qty - i.qtyallocated - i.qtypicked 可用量, i.qtyallocated 分配量, i.qtypicked 拣货量, case when i.status = \'OK\' then \'正常\' else \'冻结\' end 库存状态, case when i.status = \'OK\' then \'合格\' when i.status = \'HOLD\' and ih.status is not null then to_char(ihc.description) else to_char(ihcloc.description) end 冻结状态 from lotxlocxid i ) select * from a where 1=1 ${if(len(kczt)==0,\"\",\"and 库存状态=(\'\"+kczt+\"\')\")} ${if(len(jhl)==0,\"\",\"and 拣货量=(\'\"+jhl+\"\')\")} ${if(len(参数)==0,\"\",\"and case when 拣货量>0 then \'大于0\' when 拣货量=0 then \'等于0\' else \'小于0\' end =\'\"+参数+\"\'\")}
    2020-12-11 11:17 
  • 3关注人数
  • 445浏览人数
  • 最后回答于:2020-12-11 10:12
    请选择关闭问题的原因
    确定 取消
    返回顶部