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

oracle 查询语句后面的where条件为null不需要
select fee.deptid,sum(fee.feeamount) fy,fee.feetype,dep.deptname,ftype.paramname fylb,a.amount as hj from FEE_ACCOUNT fee
inner join sys_dept dep on fee.deptid=dep.deptid
inner join sys_dict ftype on ftype.dictid = fee.feetype
inner join 
(select fee.deptid,sum(fee.feeamount) amount from FEE_ACCOUNT fee
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) 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

你可能感兴趣的:(oracle 查询语句后面的where条件为null就不需要)