Results 1 to 9 of 9

Thread: Percentage

  1. #1
    Join Date
    Feb 2009
    Posts
    38

    Unanswered: Percentage

    Hi I have 3 tables and i must find the percentage for each code_w.
    the first table is

    DP and has
    code_w and amount

    the table WORK has code_w

    and the table EP has code_w,total_amount

    I must sum from DP the amounts(*100) per code and then divide by the total amount per code. I managed to find the amounts for each table but if i try to divide them it says "TOO MANY VALUES". Pls I appreciate some help.
    Thats what i done for each table. How will i divide the amounts? Thank you.

    SELECT WORK.COD_W,SUM (DP.AMOUNT)*100
    FROM WORK JOIN DP
    ON DP.COD_W=WORK.COD_W
    GROUP BY WORK.COD_W

    1, 4150000
    2, 1050000
    3, 96000000

    SELECT WORK.COD_W,SUM (EP.TOTAL_AMOUNT)
    FROM WORK JOIN EP
    ON EP.CODE_W=WORK.CODE_W
    GROUP BY WORK.CODE_W

    1, 44000
    2, 9000
    3, 1300000

    Must have
    1, 4150000/44000
    2, 1050000/9000
    3, 96000000/130000

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    So this has nothing to do with Oracle & is a simple arithmetic percentage calculation.
    Please proceed to do so.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Feb 2009
    Posts
    38
    Quote Originally Posted by anacedent
    So this has nothing to do with Oracle & is a simple arithmetic percentage calculation.
    Please proceed to do so.
    in oracle i have this mistake. TOO MANY VALUES

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >in oracle i have this mistake. TOO MANY VALUES
    If you say so.

    You have tables. I don't.
    You have data. I don't.
    You have SQL. I don't.

    You provide no DDL.
    You provide no DML.
    You provide no SQL.

    If you can provide solution, without DDL, DDM, SQL; please knock yourself up.

    I don't know anyone who can do so.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Feb 2009
    Posts
    38
    Quote Originally Posted by anacedent
    >in oracle i have this mistake. TOO MANY VALUES
    If you say so.

    You have tables. I don't.
    You have data. I don't.
    You have SQL. I don't.

    You provide no DDL.
    You provide no DML.
    You provide no SQL.

    If you can provide solution, without DDL, DDM, SQL; please knock yourself up.

    I don't know anyone who can do so.
    i dont know what you re talking about. i m sorry but its my second day in oracle and my second day in forum. i' ll try to understand and give the needed informations. i dont try to be smart i dont have idea about all this. sorry again i ' ll try my best. Thank you for your patience.

    ps . problem solved , i found the way.

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >ps . problem solved , i found the way.
    So please post solution for those who search forum in future.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  7. #7
    Join Date
    Feb 2009
    Posts
    38
    Select Ep.code_w,sum (dp.amount)*100/sum (distinct Ep.total_amount) As Percentage
    From Ep Join Dp
    On Ep.code_w=dp.code_w
    Group By Ep.code_w

  8. #8
    Join Date
    Jan 2009
    Location
    Dhaka, Bangladesh
    Posts
    51
    I think the following will work for you

    SELECT WORK.COD_W
    , ( (SUM (DP.AMOUNT)*100)/SUM (EP.TOTAL_AMOUNT) )
    FROM WORK , DP, EP
    WHERE DP.COD_W=WORK.COD_W
    AND EP.CODE_W=WORK.CODE_W
    GROUP BY WORK.COD_W
    Mohammad Hasan Shaharear
    E-mail
    Blog: http://shaharear.blogspot.com

  9. #9
    Join Date
    Feb 2009
    Posts
    38
    Quote Originally Posted by hasan_uiu
    I think the following will work for you

    SELECT WORK.COD_W
    , ( (SUM (DP.AMOUNT)*100)/SUM (EP.TOTAL_AMOUNT) )
    FROM WORK , DP, EP
    WHERE DP.COD_W=WORK.COD_W
    AND EP.CODE_W=WORK.CODE_W
    GROUP BY WORK.COD_W
    Thanks a lot

Posting Permissions

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