最近在画报表, 有个嵌套列表, 当没有查询到数据时列表不显示,也要显示空表格
用union并集查询
利用rownum大于0的特性,控制结果, 具体实现如下:
select rn, id,zgbzj,tzgsmc,tzje,cgbl from (
select rownum rn, id,zgbzj,tzgsmc,tzje,cgbl from TABLENAME z where jobid = $P{jobid}
union
select -1 rn,null,null,null,null,null from dual
)
where rn >= decode ( ( select count(0) from TABLENAME where jobid = $P{jobid} ) ,0, -1, 1)