title: MySQL coalesce for some null, not all null
body: <p>I have a MySQL query that checks an employee schedule DB and (thanks to a previous stackoverflow question) returns any days that the user is not working as "No Work", so that if the user isn't working on Thursday, the query fills in that date even though the date does not appear in the original result set (and so I don't have to fill in those blanks via the PHP script).</p>
  
  <p>Now the problem is that if the user is checking the schedule two weeks from now, it shows "No Work" for the entire week. If there are NO results, the script should output "Sorry, No Schedule posted for this week", so the user doesn't get mislead into thinking he has the week off and knows to check back later.</p>
  
  <p>So the question is:
  What is the best query syntax for something like:</p>
  
  <pre><code>SELECT 
  If Count(*) &gt; 0 {
  COALESCE(gooddata, nulldata) AS thedata
  etc.
  etc.
  FROM sched_table
  WHERE dates BETWEEN xxx AND yyy
  </code></pre>
  
  <p>So that it doesn't return any rows if all rows are null (or count is 0).</p>
  
  <p>I tried adding a column for a count and having the script output "not posted" and quitting after one iteration, but then on good weeks it still quits after one iteration, so I'm getting frustrated.</p>
  
  <p>I'm sure I can get the script to do what I want if I just take a step back, but I'm very curious if there is a way to do it in the query so that there has to be at least one row of non-Null values for it to coalesce the other null rows.</p>