Hi Shestakov,

According to your suggestion I have tried to create union query but I am getting this error. Actually the requirement of the report is similar to the below example, I mean I have to use group functions.

select deptno, sum(sal) from emp
where _opt_no = 1
UNION
select deptno, sum(comm) from emp
where _opt_no = 2
group by deptno
order by deptno

SQL> /
select deptno, sum(sal) from emp
*
ERROR at line 1:
ORA-00937: not a single-group group function

Is there any other way to get it done, Or do I have to change the query to make it correct.

Regards,
aph