title: Counting TINYINT values in MySQL
body: <p>The table structure is like this:</p>
  
  <pre><code>actions: int(10)
  unlock: tinyint(1)
  user_id: int(20)
  name: varchar(50)
  </code></pre>
  
  <p>I have such query:</p>
  
  <pre><code>SELECT SUM(actions) AS "sum_actions", SUM(unlock) AS "sum_unlock", user_id, name 
   FROM mytable AS `Results` WHERE user_id != 0 GROUP BY user_id 
   ORDER BY sum_actions DESC LIMIT 0,300
  </code></pre>
  
  <p>This gives <code>#1064 - You have an error in your SQL syntax</code> error.</p>
  
  <p>When I remove <code>SUM(unlock) AS "sum_unlock"</code> then query works. So I thought that it is not possible to summing TINYINTs. So I changed to <code>COUNT(unlock) as "count_unlock"</code> but this didn't help. I don't want to change "unlock" table to INT because it only has boolean values. How can I count the unlock table with summing for each user_id ?</p>