Is there any way to convert following query to laravel query builder?
$standing =DB::select("SELECT DISTINCT
users.id,
username,
SUM(points) AS pts,
count(users_games.user_id) AS CountGame,
(SELECT count(user_id) FROM users_games WHERE points=3 AND user_id=users.id ) AS win,
(SELECT count(user_id) FROM users_games WHERE points=0 AND user_id=users.id ) AS los,
(SELECT count(user_id) FROM users_games WHERE points=1 AND user_id=users.id ) AS draw
FROM users_games,users
WHERE users_games.user_id=users.id
AND score_home IS NOT NULL
AND score_away IS NOT NULL
AND points IS NOT NULL
GROUP BY users.id
ORDER BY pts DESC,win DESC,draw DESC,CountGame DESC");
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire