Last active
May 18, 2016 00:00
-
-
Save Danyboy/d94421387e5a67a85880c26cc8f01ba2 to your computer and use it in GitHub Desktop.
Revisions
-
Danyboy revised this gist
May 18, 2016 . 1 changed file with 14 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,14 @@ SELECT id, link, name, hours_together, coef FROM ( SELECT my_users.user_id, COUNT (*)::float / 12 AS hours_together, COUNT(*)::float / user_coef.their_hours AS coef FROM online{$current_user} LEFT JOIN online{$current_user} AS my_users ON my_users.status = online{$current_user}.status INNER JOIN (SELECT user_id, COUNT(*) AS their_hours FROM online{$current_user} GROUP BY user_id) AS user_coef ON user_coef.user_id = my_users.user_id WHERE online{$current_user}.user_id = {$user} GROUP BY online{$current_user}.user_id, my_users.user_id, user_coef.their_hours ORDER BY hours_together DESC ) AS my_comp JOIN users{$current_user} ON (my_comp.user_id = id); -
Danyboy created this gist
May 17, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ SELECT id, link, name, hours_together, coef FROM ( SELECT my_users.user_id, COUNT (*)::float / 12 AS hours_together, COUNT(*)::float / user_coef.their_hours AS coef FROM online{$current_user} LEFT JOIN online{$current_user} AS my_users ON my_users.status = online{$current_user}.status INNER JOIN (SELECT user_id, COUNT(*) AS their_hours FROM online{$current_user} GROUP BY user_id) AS user_coef ON user_coef.user_id = my_users.user_id WHERE online{$current_user}.user_id = {$user} GROUP BY online{$current_user}.user_id, my_users.user_id, user_coef.their_hours ORDER BY hours_together DESC ) AS my_comp JOIN users{$current_user} ON (my_comp.user_id = id);