SELECT id_shop,shop_no,shop_name,totol_vote,count_vote,score,avg
FROM (SELECT totol.totol_vote,people_vote.count_id,people_vote.vote_for,people_vote.score,people_vote.count_vote,ROUND(people_vote.score/people_vote.count_vote,2) as avg
FROM(SELECT vote_for,count(*)as count_vote,sum(vote_score) as score,count(id_uservote) as count_id
FROM vote WHERE vote_type=1 and vote_datetime BETWEEN '2015-02-02' and '2015-02-08' GROUP BY vote_for) as people_vote,
(SELECT count(id_uservote) as totol_vote FROM vote WHERE vote_type=1 and vote_datetime BETWEEN '2015-02-02' and '2015-02-08') as totol) as weeker
INNER JOIN shop_data b ON weeker.vote_for=b.id_shop order by count_vote DESC,score DESC,avg DESC