title: Postgresql CASE WHEN to extract max and min date
body: <p>Here's the problem occurred.</p>
  
  <p><img src="https://i.stack.imgur.com/3ebuQ.png" alt="enter image description here"></p>
  
  <p>What I trying to do was add status to the table according to their starting time.</p>
  
  <p>However, all the status turned out to be 'shortest serving' which is pretty weird.</p>
  
  <p>Can somebody explain it and fix the problem?</p>