1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Display Total Salary of the organization along with Employee Details in one row

Discussion in 'SQL PL/SQL' started by mist, Jan 3, 2014.

  1. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Hi all,

    Display Total Salary of the organization along with Employee Details in one row below example gives me all rows of "total_sal" 29025

    select a.empno, a.ename, a.deptno, a.sal, b.total_sal
    from emp a,
    (select sum(sal) total_sal from emp b) b

    Thank You
     
  2. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi mist,

    You want to display all records in one row like below?
    Code (SQL):

    SUM(SAL)          ENAMES
    ----------------------------------------------------------------------------------------
    29025   SMITH,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,FORD,MILLER
     
  3. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Hi Jagadekara,

    Thank You for reply & sorry for the late. Yes correct,i want to display all records in one row like the above..

    Thank You
     
  4. jagadekara

    jagadekara Forum Guru

    Messages:
    1,126
    Likes Received:
    145
    Trophy Points:
    1,805
    Location:
    Pulivendula
    Hi check below query.

    select sum(sal),
    rtrim(xmlagg(xmlelement (e, ename || ',')).extract ('//text()'), ',') enames
    from
    emp
     
    mist likes this.
  5. mist

    mist Active Member

    Messages:
    59
    Likes Received:
    2
    Trophy Points:
    160
    Thank You It is working now..:)
     
  6. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,345
    Likes Received:
    347
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    And where is the query the original poster wrote to solve this problem? I do not see it in this thread. Simply giving out answers to such questions is a disservice to the person who posted the question as it teaches little and explains even less.


    It is the forum policy to not do other's work but to assist them in arriving at the correct solution.