1. Registered User
Join Date
Feb 2009
Posts
38

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. Registered User
Join Date
Aug 2003
Location
Where the Surf Meets the Turf @Del Mar, CA
Posts
7,776
So this has nothing to do with Oracle & is a simple arithmetic percentage calculation.

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

4. Registered User
Join Date
Aug 2003
Location
Where the Surf Meets the Turf @Del Mar, CA
Posts
7,776
>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.

5. Registered User
Join Date
Feb 2009
Posts
38
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. Registered User
Join Date
Aug 2003
Location
Where the Surf Meets the Turf @Del Mar, CA
Posts
7,776
>ps . problem solved , i found the way.
So please post solution for those who search forum in future.

7. Registered User
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. Registered User
Join Date
Jan 2009
Location
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

9. Registered User
Join Date
Feb 2009
Posts
38
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
•