SELECT p.SKU, p.mhSlug, p.mhDescription, p.cgSlug, p.cSlug, IF(p.CommonBrandName = 'LG Appliances','LG',p.CommonBrandName) AS CommonBrandName, p.CommonBrandName AS BrandName, bd.CommonBrandID, IF(p.StandardColor = 'Other',CONCAT(UCASE(SUBSTRING(p.ColorDescription, 1, 1)),LCASE(SUBSTRING(p.ColorDescription, 2))),p.StandardColor) AS ModelColor, p.StandardColor, p.ColorDescription, mp.MSRP, mp.Sale, mp.Available, mp.Featured, IF((mp.Sale = 0), mp.MSRP, IF( (mp.MSRP = 0), mp.Sale, IF((mp.Sale > mp.MSRP), mp.MSRP, mp.Sale))) AS calcPrice, IF(mp.MSRP > 0 AND mp.MSRP > mp.Sale, mp.MSRP, '0.00') AS RegPrice, mp.OutletPrice, mp.quick_ship, mp.PowerBuy, (mp.MSRP - mp.Sale) AS Discount, mp.in_stock, mp.free_shipping, p.Sale AS MinTargetPrice, mp.FreeShip, bd.UMRP, (p.Sale * (IF(bd.MAP = 1 OR p.is_package = 1, 1,.90))) AS MAP, (SELECT COUNT(pbm.pkID) FROM PromotionsByModel AS pbm INNER JOIN Rebates ON (Rebates.PromotionName = pbm.PromotionName AND Rebates.FileName <> '') WHERE pbm.pkProduct = p.pkID AND pbm.EffectiveDate <= CURDATE() AND pbm.ExpirationDate > CURDATE() GROUP BY pbm.pkProduct) AS rwsPromotion, (SELECT COUNT(rbm.pkID) FROM rebatesbymodel AS rbm INNER JOIN Rebates AS r ON r.pkID = rbm.pkRebates WHERE rbm.pkProduct = p.pkID AND r.ExpirationDate > CURDATE() AND r.EffectiveDate < CURDATE() GROUP BY rbm.PromotionName) AS rwsRebates FROM Categories AS c INNER JOIN Category_Groups AS cg ON (c.Category_Group = cg.CategoryCode) INNER JOIN menu_heading AS mh ON (cg.MenuHeading = mh.id) INNER JOIN tbl_products AS p ON (p.cSlug = c.slug AND p.cgSlug = cg.slug AND p.mhSlug = mh.slug) INNER JOIN Brand_Data AS bd ON (bd.pkID = p.pkBrand) INNER JOIN tbl_store_brands AS sb ON (sb.brandID = bd.pkID AND sb.categoryID = c.pkID ) INNER JOIN ModelPrice AS mp ON (mp.pkProduct = p.pkID AND mp.SKU = p.SKU AND mp.Available = 1 ) WHERE 0=0 GROUP BY p.SKU ORDER BY IF(calcPrice = 0,99999, calcPrice) ASC

Sort aborted: Query execution was interrupted