title: SQL case expression is not giving desired result
body: <p>I have the following situation. Sample data:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>OCTeamID (int)</th>
  <th>OCTeamLastTime (datetime)</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1970-01-01 00:00:00</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2022-01-21 00:37:23</td>
  </tr>
  <tr>
  <td>3</td>
  <td>1970-01-01 00:00:00</td>
  </tr>
  <tr>
  <td>4</td>
  <td>2022-01-21 00:37:23</td>
  </tr>
  <tr>
  <td>5</td>
  <td>1970-01-01 00:00:00</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>What I am trying is the folowing:</p>
  <p>When the Datetime value in the row of column <code>OCTeamLastTime</code> is higher dan the current datetime <code>CURRENT_TIMESTAMP</code> I want a SQL variable to be <code>Now</code> otherwise use the value from <code>OCTeamLastTime</code> as <code>CanDoOC</code>.</p>
  <p>I am currently trying the folowing statement. But this gives me the result Now for every outcome.</p>
  <pre><code>SELECT OCTeamName, OCTeamID, OCTeamLastTime, (
      CASE WHEN(SELECT COUNT(OCTeamID) FROM OCTable WHERE OCTeamLastTime &gt;= CURRENT_TIMESTAMP AND OCTeamID = OCTeamID) &gt; 0 THEN 'Now' ELSE OCTeamLastTime END
  ) AS CanDoOC
  FROM OCTable
  </code></pre>
  <p>I want to use these results in a option list in php/html. Desired results based on above table:</p>
  <pre><code>&lt;option data-subtext=&quot;Next OC: &lt;?php echo $SelectOCTeam['CanDoOC']; ?&gt;&quot; value=&quot;&lt;?php echo $SelectOCTeam['OCTeamID']; ?&gt;&quot;&gt;&lt;?php echo $SelectOCTeam['OCTeamName']; ?&gt;&lt;/option&gt;
  </code></pre>
  <p>It should create 5 options in this case. With Next OC: Now for the team with ID 1,3 and 5 and the <code>OCTeamLastTime</code> value for the other options.</p>
  <p>Does anyone how to accomplish this? As what I did is not working and I cant think of any other way to make this work.</p>