select count(*) as total from (select p2c.categories_id as season,pd.products_name,IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price,p.products_price*1 as products_price,m.manufacturers_name as brand_name,p.*,(SELECT CONCAT(UCASE(LEFT(name, 1)), LCASE(SUBSTRING(name, 2))) FROM products_extra WHERE extra_key=p.wheelrim_color and type_id=2 and fk_languages_id="4" limit 1 ) as wheelrim_colors,(SELECT CONCAT(UCASE(LEFT(name, 1)), LCASE(SUBSTRING(name, 2))) FROM products_extra WHERE extra_key=p.wheelrim_finish and type_id=3 and fk_languages_id="4" limit 1 ) as wheelrim_finishes from products p left join specials s on p.products_id = s.products_id, products_description pd, manufacturers m, products_to_categories p2c where p.products_status = 1 and p.expired=0 and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = "4" and p.type=3 and p.manufacturers_id = 143 and p.expired=0 and p.products_status=1 and upper(p.wh_compatible)= "TESLA" order by final_price , pd.products_name) as t