title: mysql MIN and MAX functions with if statement
body: <p>I have an sql query like this:</p>
  
  <pre><code>SELECT IF( (SELECT COUNT(*) FROM `test_table2` WHERE `id` = t.`id`) &gt; 0,
      (t.`price` + (SELECT `price` FROM `attribute` WHERE `id` = t.`id` LIMIT 1)),
      t.`price`
  ) AS `full_price`, 
  MIN(`full_price`) as `min`, MAX(`full_price`) as `max` 
  FROM `test_table` t
  </code></pre>
  
  <p>How can i retrieve min and max values without using duplicate code in if statement?</p>
  
  <p>Thanks.</p>