I am trying to understand how to derive a percentage of values that specifically fall within multiple categories from more than two tables. For example, given a sample scenario where only a small number of adults who caught the flu died. How do you find a percentage of adults with flu that died and a percentage of adults with flu that didn't die?
There are a total of three tables pasted below for your reference. The first table has a list of people that indicate general information about the person, such as name, age, income, etc. The second table has a list of people that indicate a variety of people's illnesses, such as being sick from the flu. The last table indicates a list of people who have died and their cause of death.
How can one derive the desired output using SQL? One can also use a combination of R functions (such as merge function) as the SQL code would be run in an R environment.
Sample Table 1
Name Age Gender
Andrew 25 Male
Lisa 21 Female
Conor 35 Male
John 51 Male
Linda 29 Female
Sample Table 2
Name Illness
Andrew Flu
Conor Flu
Lisa Flu
John Smallpox
Sample Table 3
Name Cause of Death
Andrew Flu
Desired Output
Fatality(Death from Flu) Percentage of people with flu
Yes 1/3
No 2/3