Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Unanswered: How to get sum of rows group by some values that are present in other table ?

    Hello,
    lets this is the structure of my tables :

    emp_detail (table)

    P.No Dept
    001 121
    002 121
    003 123
    004 123
    005 123
    006 124

    map_table

    Dept C_Code
    121 001
    123 001
    124 002

    and my required output is :
    C_Code Emp_Count
    001 5
    002 1

    Now, as you can see Emp_Count is the sum of all employees that are present
    in 001(C_Code) i.e., 121 and 123 Dept .

    Can anyone tell me the Sql query for this output ?
    I am using Oracle 10g.

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    You'll just need to join the two tables.

Posting Permissions

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