SELECT MK.makeid, MK.makename, MD.modelid, MD.modelname, MD.logo, IF(TRIM(MD.murlid) != 0, 1,0) as storeval, MD.mscore, MD.mprice, MD.eprice, IF(TRIM( MD.mprice )!=0,MD.mprice, MD.eprice) as price, MD.murlid, MD.mstore, MD.mcount, MD.avastatus, SP.geninfo_sim, SP.geninfo_network, SP.camera_primary, SP.memory_internal, SP.memory_ram, SP.platform_opt_system, SP.battery_type, (SELECT ROUND((SUM(RT.rate)/COUNT(RT.modelid)), 1) FROM nwprd_rating as RT WHERE RT.modelid = MD.modelid GROUP BY RT.modelid) as voteRate FROM nwprd_make as MK INNER JOIN nwprd_model as MD ON MD.makeid = MK.makeid INNER JOIN nwprd_specification as SP ON SP.smodelid = MD.modelid WHERE 1=1 GROUP BY MD.modelid ORDER BY MD.avastatus DESC, storeval DESC, MD.pop_pro DESC, price ASC, MD.modelid DESC LIMIT 0, 24