title: Different Where Clause for each selected columns
body: <p>I originally had this query</p>
  
  <pre><code>SELECT
      MIN(CASE WHEN id = '001' THEN value END) Col1,  
      MIN(CASE WHEN id = '002' THEN value END) Col2,
      MIN(CASE WHEN id = '003' THEN value END) Col3,  
      MIN(CASE WHEN id = '004' THEN value END) Col4,
      MIN(CASE WHEN id = '005' THEN value END) Col5,  
      MIN(CASE WHEN id = '006' THEN value END) Col6
  
  FROM table
  WHERE id IN (001, 002, 003, 004, 005, 006) and
  
  DATE(from_unixtime(t_stamp/1000)) "2014-11-12"
  
  AND
  
  (value &gt; -5 OR value &gt; 5)
  
  
  GROUP BY DATE(from_unixtime(t_stamp/1000)), HOUR(from_unixtime(t_stamp/1000)), MINUTE(from_unixtime(t_stamp/1000)) DIV 60
  </code></pre>
  
  <p>The reason for the <code>(value &gt; -5 OR value &gt; 5)</code> for the first case (Col1) I wanted it to only get the value that is > -5, and then same for the second case (Col2) I wanted it to only get the values that is >5.</p>
  
  <p>Now I tried to use select on the where clause but it only outputted values on one column. So i thought Id change my query a little bit and so I changed it to something like this I have only done two columns first because I wanted to test it. But as soon as i hit Go its taking too long to execute. </p>
  
  <pre><code>SELECT ROUND(t1.floatvalue,3) C1, ROUND(t2.floatvalue,3) C2
  
  
  FROM table AS t1
  
  LEFT JOIN table AS t2
  
  ON from_unixtime(t1.t_stamp/1000) = from_unixtime(t2.t_stamp/1000)
  
  WHERE t1.tagid = "001" AND
  t2.tagid = "002"
  
  AND t1.floatvalue &gt; -5 AND t2.floatvalue &gt; 5
  
  AND from_unixtime(t1.t_stamp/1000) BETWEEN "2014-11-14 09:00:00" AND "2014-11-14 11:00:00"
  
  GROUP BY DATE(from_unixtime(t_stamp/1000)), HOUR(from_unixtime(t_stamp/1000)), MINUTE(from_unixtime(t_stamp/1000)) DIV 60
  </code></pre>
  
  <p>What is wrong with the second query that I did? I even specified the start and end time but still, its taking too long. (As I type its still loading)</p>
  
  <p>Any help is appreciated. Thank You!</p>