Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

problem with percentage query

542454Dec 15 2010 — edited Dec 16 2010
Hi there,

I would like to calculate percentage data in my sql query but it doesn't work. My table structure is the following :

RESOURCE TABLE:

ID_RES | ICD | CONSENT | SAMPLE_DATE

So, the goal of query is to calculate of percentage of yes with the total number. In the first step I did :

Compte ICD | Reponse | Code
2 | NON | C76.4
5 | OUI | C76.4
3 | OUI | C26.9

with the following query :

SELECT
count(RES.ICD) AS "Compte CODE en 2010",
RES.CONSENT AS "reponse",
RES.ICD AS "CODE"
FROM
RESOURCE RES
WHERE
trunc(RES."SAMPLE_DATE", 'DD') > TO_DATE('10/12/2010', 'DD-MM-YYYY')
AND RES.ICD IS NOT NULL
GROUP BY (RES.ICD, RES.CONSENT)
ORDER BY
RES.ICD

The problem is that I don't know how to integrate percentage calculus in my query in order to obtain the following result :

Compte ICD | Reponse | Code | Pourcentage oui
2 | NON | C76.4 |
5 | OUI | C76.4 | 71.42
3 | OUI | C26.9 | 100

Does anybody could help me please ?

Regards,
Jarod.
This post has been answered by Frank Kulash on Dec 16 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2011
Added on Dec 15 2010
5 comments
316 views