DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Sql Query for the specified format!

  1. #1
    Join Date
    Feb 2001
    Posts
    286
    Hi all!

    Query:

    1.I would like to have a query which produces the output as under from the following table:


    SQL>DESC SS

    NAME NULL? TYPE
    ENO NUMBER(2)
    ENAME VARCHAR2(10)
    DR_CR CHAR(1)
    SAL NUMBER(7,2)


    SQL> SELECT * FROM SS;


    ENO ENAME DR_CR SAL

    11 AAA D 1000
    12 BBB D 1000
    11 AAA C 500
    12 BBB C 500
    11 AAA D 2000
    12 BBB D 300


    6 rows selected.


    The output should be like this:


    ENO ENAME SUM(AMT)D SUM(AMT)C

    11 AAA 3000 500
    12 BBB 1300 500


    Thanks & Regards,


    Amit.


    Oracle DBA (OCP) v8i,v9i

  2. #2
    Join Date
    Feb 2002
    Posts
    13
    SELECT ENO, ENAME, SUM(DECODE(CR_DR,'D',SAL,0) D,
    SUM(DECODE(CR_DR,'C',SAL,0) C
    FROM SS
    GROUP BY ENO, ENAME;

  3. #3
    Join Date
    Feb 2001
    Posts
    286

    Thanks Wroos!

    Many Thanks Wroos!

    Regards,

    Amit.
    Oracle DBA (OCP) v8i,v9i

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width