title: How does one perform math on multiple SELECT results?
body: <p>I have an sql table of PlayerTrial that holds, well, player trials.</p>
  
  <pre><code>---PlayerTrials Basic Layout---
  int id
  int playerid
  bool flagA
  bool flagB
  bool flagC
  </code></pre>
  
  <p>I want to determine the % of trials a player has done with flags B and C set.</p>
  
  <p>To do so, I know I have to:</p>
  
  <p>1) Select the total trials by a single player</p>
  
  <pre><code>SELECT COUNT( * ) from playertrial WHERE playerid = _
  </code></pre>
  
  <p>2) Select the total trials with flagB and flagC true</p>
  
  <pre><code>SELECT COUNT( * ) from playertrial WHERE playerid = _ AND flagB = true AND flagC = true
  </code></pre>
  
  <p>3) divide 2 by 1 to determine the % of trials with flags B+C set</p>
  
  <pre><code>brain explode.
  </code></pre>
  
  <p>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?</p>