您的位置:首页 > 数据库 > Oracle

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

2013-08-29 10:34 453 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: