SQL
AخA
USE cswiki_p;
SELECT log.log_title as gets_thx, log.log_user_text as gives_thx, COUNT(*) as cnt, min(log.log_id) as log_id_min
FROM logging as log,
(
SELECT log_title as user, COUNT(*) as cnt_gets
FROM logging
WHERE log_type="thanks" AND log_id > 1200000
GROUP BY log_title
) as gets, /*those who were thanked by someone*/
(
SELECT log_user_text as user, COUNT(*) as cnt_gives
FROM logging
WHERE log_type="thanks" AND log_id > 1200000
GROUP BY log_user_text
) as gives /*those who thanked to someone*/
WHERE log.log_type="thanks" AND log.log_id > 1200000
AND gets.cnt_gets > 10 AND gets.cnt_gets + gives.cnt_gives > 20
AND gives.user = log.log_user_text AND gets.user = log.log_title
GROUP BY log_title, log_user_text
ORDER BY COUNT(*) DESC
LIMIT 10000;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.