G
Guest
I have a query that extracts specific information out of my Diag2005 table.
The sql view is provided, and the resulting output. What I need to be able to
do is get a sum of PDX by PA, ie. I need to have the sum of PDX diagnoses
102+103 by PA (ASC-PA), sum of PDX diagnoses 104+108+109+110 by PA (SIL-PA),
and then be able to provide a ratio by PA ASC-PA/SIL-PA. How do I do this?
SELECT Diag2005.PA, Diag2005.PDX, Count(Diag2005.PDX) AS Tot_PA
FROM Diag2005
GROUP BY Diag2005.PA, Diag2005.PDX
HAVING (((Diag2005.PDX)=102 Or (Diag2005.PDX)=103 Or (Diag2005.PDX)=104 Or
(Diag2005.PDX)=108 Or (Diag2005.PDX)=109 Or (Diag2005.PDX)=110))
ORDER BY Diag2005.PA;
PA PDX Tot_PA
13 102 390
13 103 39
13 104 246
13 108 65
13 109 3
13 110 2
16 102 84
16 103 5
16 104 44
16 108 10
18 102 532
18 103 40
18 104 298
18 108 35
18 109 2
22 102 75
22 103 6
22 104 34
22 108 2
The sql view is provided, and the resulting output. What I need to be able to
do is get a sum of PDX by PA, ie. I need to have the sum of PDX diagnoses
102+103 by PA (ASC-PA), sum of PDX diagnoses 104+108+109+110 by PA (SIL-PA),
and then be able to provide a ratio by PA ASC-PA/SIL-PA. How do I do this?
SELECT Diag2005.PA, Diag2005.PDX, Count(Diag2005.PDX) AS Tot_PA
FROM Diag2005
GROUP BY Diag2005.PA, Diag2005.PDX
HAVING (((Diag2005.PDX)=102 Or (Diag2005.PDX)=103 Or (Diag2005.PDX)=104 Or
(Diag2005.PDX)=108 Or (Diag2005.PDX)=109 Or (Diag2005.PDX)=110))
ORDER BY Diag2005.PA;
PA PDX Tot_PA
13 102 390
13 103 39
13 104 246
13 108 65
13 109 3
13 110 2
16 102 84
16 103 5
16 104 44
16 108 10
18 102 532
18 103 40
18 104 298
18 108 35
18 109 2
22 102 75
22 103 6
22 104 34
22 108 2