Help speed this MySQL query which is taking too long because of an aggregate function

Posted by Joseph on Stack Overflow See other posts from Stack Overflow or by Joseph
Published on 2010-05-03T19:33:23Z Indexed on 2010/05/03 19:48 UTC
Read the original article Hit count: 322

Filed under:
|

Hi all,

I am using a following query in MySQL for fetching data from a table. Its taking too long because the conditional check within the aggregate function.Please help how to make it faster

SELECT testcharfield 
     , SUM(IF (Type = 'pi',quantity, 0)) AS OB
     , SUM(IF (Type = 'pe',quantity, 0)) AS CB
  FROM Table1
 WHERE sequenceID = 6107
 GROUP BY testcharfield 

© Stack Overflow or respective owner

Related posts about mysql

Related posts about Performance