Самые активные сортировка по рецензий день выкидываем тех кого меньше

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Самые активные (сортировка по рецензий/день, выкидываем тех, у кого меньше 10 рецензий) */
SELECT su.login,su.user_id,
COUNT(*) AS total,
ROUND(COUNT(*)/(TO_DAYS(CURDATE())-TO_DAYS(su.make_date)),2) AS per_day,
ROUND(SUM(f.num_vote_ok)*100/(SUM(f.num_vote_ok)+SUM(f.num_vote_no)),2) AS useful
FROM forum f
INNER JOIN shop_user su ON (su.user_id=f.id_user)
WHERE f.type_mess='forum' AND f.report_type=''
AND f.view=''
GROUP BY f.id_user HAVING total>10
ORDER BY per_day DESC
LIMIT 100;
/* Самые активные (сортировка по полезности, выкидываем тех, у кого меньше 10 рецензий) */
SELECT su.login,su.user_id,
COUNT(*) AS total,
ROUND(COUNT(*)/(TO_DAYS(CURDATE())-TO_DAYS(su.make_date)),2) AS per_day,
ROUND(SUM(f.num_vote_ok)*100/(SUM(f.num_vote_ok)+SUM(f.num_vote_no)),2) AS useful
FROM forum f
INNER JOIN shop_user su ON (su.user_id=f.id_user)
WHERE f.type_mess='forum' AND f.report_type=''
AND f.view=''
GROUP BY f.id_user HAVING total>10
ORDER BY useful DESC
LIMIT 100;