Queries calulating ratio

Lifeseeker

Registered User.
Local time
Today, 10:31
Joined
Mar 18, 2011
Messages
273
Hi,

I have a simple query like below.

Code:
SELECT [score_admit] / SELECT [score_discharge] AS Ratio, facility_type
FROM tbl_test
group by facility_type;

It's really just based on one table, but what I'm trying to do is to calculate the ratio for the scores, then arrange the result based on facility types.

The error I get is a syntax error the SELECT statements.

Can anyone help out?

Thanks
 
Remove the second select.

SELECT [score_admit]/[score_discharge] AS Ratio, facility_type FROM tbl_test group by facility_type;
 
You have two problems

You don't need the second select
you have grouped by facility type but not stated whether it is the sum or average for ratio or the sum of score admit/sum or score discharge (have assumed this is what you want

Code:
SELECT sum([score_admit]) / sum([score_discharge]) AS Ratio, facility_type
FROM tbl_test
group by facility_type;
 

Users who are viewing this thread

Back
Top Bottom