problem with percentage query
542454Dec 15 2010 — edited Dec 16 2010Hi 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.