I have an sql table of PlayerTrial that holds, well, player trials.
---PlayerTrials Basic Layout---
int id
int playerid
bool flagA
bool flagB
bool flagC
I want to determine the % of trials a player has done with flags B and C set.
To do so, I know I have to:
1) Select the total trials by a single player
SELECT COUNT( * ) from playertrial WHERE playerid = _
2) Select the total trials with flagB and flagC true
SELECT COUNT( * ) from playertrial WHERE playerid = _ AND flagB = true AND flagC = true
3) divide 2 by 1 to determine the % of trials with flags B+C set
brain explode.
I know how to do the individual queries for both one and two. And of course I could store them in a temporary table or something. But I’m sure there’s a way to join them into one query, and I have fried my brain trying all the SQL combos I know such that I don’t have a clue what to try next. Any ideas?
1 Answer