title: I have to optimize and reduce the performance for below mysql query
body: <pre><code>SELECT income_range, count(*) AS count FROM
  
  (SELECT CASE WHEN (income &gt;=0 and income &lt;= 250000) THEN 'range1' 
  
  WHEN (income &gt;= 250000 and income &lt;= 1000000) THEN 'range2' 
  
  when (income &gt;= 1000000 and income &lt;= 2500000) THEN 'range3'
  
  when (income &gt;= 2500000) THEN 'range4' END as income_range FROM subscriber_data,entities 
  
  where exists (select * from entities where entities.id in (31) )  
  
  and (subscriber_data.entity_uid = entities.channel_uid 
  
  and subscriber_data.channel_id = entities.channel_id)
  
  and Lower( subscriber_data.status) in ( 'active','expired') 
  
  and Lower( subscriber_data.status) in ( 'active') )
  
  AS INCOME_SUMMARIES GROUP BY income_range
  </code></pre>
  
  <p>output:-
  income_range  count
  range1         2796
  range2          374
  range3          749
  range4           3079</p>