1 Reply Latest reply: Aug 17, 2013 2:53 PM by Asif Muhammad RSS

    SQL Query


      Hello All,

      I am using Oracle 10G for SQL.

      I have a query which returns records as shown below


      sql> select * from emp

      Empno  Sal   Comm OT

      10          100   

      10                   120

      10                              300



      Instead of the records getting displayed multiple times, I would like to display them as 1 record

      as shown below

      Empno  Sal   Comm  OT

      10          100    120     300


      How is this possible ?





        • 1. Re: SQL Query
          Asif Muhammad

          Hi Im,


          If the Emp No is unique, and the data in the next 3 column is pertaining to colum EMP no. Why don't you just group and sum the rest of the column as:


          SELECT empno, sum(sal), sum(comm), sum(ot)

          FROM emp

          group by empno;


          Thanks &

          Best Regards,