Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> SQL - UNION statement

SQL - UNION statement

From: <suisum_at_ecn.ab.ca>
Date: 8 Dec 98 01:20:43 GMT
Message-ID: <366c7eeb.0@ecn.ab.ca>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US