I have a user table like this
FIRSTNAME | LASTNAME | ID |
--------------------------------
James | Hay | 1 |
Other | Person | 2 |
I also have an attendance table like this
EVENTID | USERID | ATTENDANCE | STATUS |
-----------------------------------------------
1 1 True 3
2 1 False 1
3 1 False 3
1 2 False 1
2 2 True 3
3 2 True 3
Basically, when a user is invited to an event, a row is added to the attendance table which has the event ID, their user ID, false attendance, and status 0.
Status is just an indicator of their response
0 = No Response
1 = Said No
2 = Said Yes
3 = Said yes and seats confirmed
My end result I want to get from querying these two tables is quite complicated and I can’t figure out what I need to do.
I want to get a result like this
NAME | % of saying YES to an RSVP | % of attending after saying yes
-------------------------------------------------------------------------------
James Hay | 66 | 50
Other Person | 66 | 100
I’m sure you can work out how I got those numbers but to explain, James Hay had the 3 (yes) status to 2/3 events invited to. So % of saying yes is 66. Out of the 2 he said yes to, he only attended 1/2 so % of attending after saying yes is 50%
Any push in the right track would be much appreciated here since I can’t get my head around this.
EDIT:
Also something quite important is that I want the results to include every user in the database even if they have 0 rows in the attendance table.
1 Answer