All pastes #501705 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-22 05:22 UTC
rendered paste body
SET @result_num:=0;
CREATE TEMPORARY TABLE table_name SELECT (@result_num:=@result_num+1) as rank,avg( actual_rating ) as rar, being_rated, count(*) FROM ratings GROUP BY being_rated HAVING count(*)>=2 ORDER BY avg(actual_rating) desc;

CREATE TEMPORARY TABLE table_two SELECT  u.name, t.rar, u.uid FROM users AS u INNER JOIN table_name AS t where u.uid = t.being_rated;

select * from table_two;