| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> SQL - UNION statement
Hi all:
Anyone know what the purpose of the following SQL statement? Why we need
UNION?
CURSOR td_curs IS
SELECT sum(expen_amount) expen_amount,
e.disb_no,
d.description
from expense e,
descriptions d,
disb_table dt
where e.client_no = :top.client_no
and e.matter_no = :top.matter_no
and e.new_journal_type = 'XX'
and e.disb_no = '000'
and e.disb_code = d.record_no
and e.tran_date <= to_date(:TOP.RE_DATE, :TOP.DATE_FORMAT)
and e.disb_no = dt.disb_no
group by e.disb_no, description
UNION
SELECT sum(expen_amount) expen_amount,
e.disb_no,
dt.disb_descrip
from expense e,
descriptions d,
disb_table dt
where e.client_no = :top.client_no
and e.matter_no = :top.matter_no
and e.new_journal_type = 'XX'
and e.disb_no != '000'
and e.disb_code = d.record_no
and e.tran_date <= to_date(:TOP.RE_DATE, :TOP.DATE_FORMAT)
and e.disb_no = dt.disb_no
group by e.disb_no, dt.disb_descrip
order by 2;
--
Best regards,
Received on Mon Dec 07 1998 - 19:20:43 CST
![]() |
![]() |