oracle 查询语句后面的where条件为null就不需要

来源:互联网 发布:中国农业大学网络 编辑:程序博客网 时间:2024/05/18 22:12
oracle 查询语句后面的where条件为null不需要
select fee.deptid,sum(fee.feeamount) fy,fee.feetype,dep.deptname,ftype.paramname fylb,a.amount as hj from FEE_ACCOUNT feeinner join sys_dept dep on fee.deptid=dep.deptidinner join sys_dict ftype on ftype.dictid = fee.feetypeinner join (select fee.deptid,sum(fee.feeamount) amount from FEE_ACCOUNT feewhere   (fee.feetype=$P{feetype} or $P{feetype} is null  ) and (fee.deptid = $P{deptid} or $P{deptid} is null)  and   to_char(fee.Filldate,'yyyy-mm-dd')>=$P{startdate} and to_char(fee.Filldate,'yyyy-mm-dd')<=$P{enddate}group by fee.deptid) a on a.deptid = fee.deptid where  (fee.feetype=$P{feetype} or $P{feetype} is null  ) and (fee.deptid = $P{deptid} or $P{deptid} is null) and to_char(fee.Filldate,'yyyy-mm-dd')>=$P{startdate} and to_char(fee.Filldate,'yyyy-mm-dd')<=$P{enddate}group by fee.deptid,fee.feetype,dep.deptname,ftype.paramname,a.amount order by fee.deptid

原创粉丝点击