title: MySQL query to count non-null values in a single row
body: <p>I'm trying to put together a MYSQL query that will count the number of Non-Null (or better yet, non-zero) values in select fields in a single row and then sort from lowest to highest (based on the count).  For example, I have a table with 5 fields... ID, Name, Score_1, Score_2, Score_3.  I want to count how many times the value "0" exists in Score_1, Score_2 and Score_3 for each record, then sort from most non zero values to least.  </p>
  
  <pre>
  ID   Name   Score_1   Score_2   Score_3
  1    Dan    8         7         0
  2    Joe    0         0         3
  3    Chris  0         0         0
  4    Mike   4         5         5
  </pre>
  
  <p>I assume the query has to look something like this...</p>
  
  <p>Select ID, Name, Score_1, Score_2, Score_3 where (???) ORDER BY (???)</p>
  
  <p>Output should look like this (ID 4 is displayed first since it has the least amount of non-zero entries)...</p>
  
  <pre>
  ID   Name   Score_1   Score_2   Score_3
  4    Mike   4         5         5
  1    Dan    8         7         0
  2    Joe    0         0         3
  3    Chris  0         0         0
  </pre>
  
  <p>I'm somewhat new to mysql query's, so any help would be greatly appreciated.  I thought the COUNT function would help, but that function appears to count columns from all rows.  Perhaps there is a way to use the COUNT function and limit it to a singel row so it can be sorted by that row count?</p>