title: Applying CASE WHEN to MIN/MAX
body: <p>I'm trying to apply <code>MIN/MAX</code> to my <code>SELECT</code> clause based on two criteria. (See Below). When I try to reference my column <code>submitted_at</code> in another query, it says the column reference is ambiguous.  </p>
  
  <pre><code>MIN(CASE WHEN (document != 'dphoto' AND document_type != 'dlicenses' AND 
  status = 'upload') THEN occurred_at END) AS submitted_at,`
  
  MAX(CASE WHEN (document_type = 'dphoto' AND document_type = 'dlicenses' AND
  status = 'upload') THEN occurred_at END) AS submitted_at`  
  </code></pre>
  
  <p>I've attempted to consolidate the phrase into 1 select but have been unsuccessful. Any tips are appreciated</p>