title: Complex (or impossible) Select from mysql table
body: <p>I have a <code>mysql</code>table like this:</p>
  
  <pre><code>Person     x     minutes     population
  p1         F     3           p1p2p3p4
  p2         B     1           p1p2p3p4
  p1         B     7           p1p2p3
  p3         F     2           p2p3p1
  p1         F     3           p1p2
  p1         B     4           p2p3p1
  p2         C     3           p1p2p3
  p2         B     1           p2p1p3
  p2         F     7           p2p3p4
  p3         B     2           p2p3p4
  p1         F     3           p2p1p3p4
  </code></pre>
  
  <p>What I need to select, for each <code>Person</code> is:</p>
  
  <p>1- Count the number of times x is equal to <code>F</code>;</p>
  
  <p>2- Count the number of times x is equal to <code>B</code>;</p>
  
  <p>3- Sum the value of <code>minutes</code>when the <code>person</code>appears in the variable <code>population</code>;</p>
  
  <p>Then, the resulting <code>select</code>would be like this:</p>
  
  <pre><code>Person    nF    nB    tminutes
  p1        3     2     24
  p2        1     2     36
  p3        1     1     33
  </code></pre>
  
  <p>I am not sure if this is even possible. I have tried something like:</p>
  
  <pre><code>SELECT 
   Person,
   sum(x='F') as nF,
   sum(x='B') as nB,
   sum(minutes) WHERE population IS LIKE '%Person%' as tminutes
  FROM myTable
  GROUP BY Person
  </code></pre>
  
  <p>Any ideas would be very welcome! Thanks.</p>