Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/08/2021 in all areas

  1. If you want it in a single query, initialize the variables in a joined subquery SELECT , (@csumA := @csumA + A) as cumulative_A , (@csumM := @csumM + M) as cumulative_M , (@csumE := @csumE + E) as cumulative_E , (@csumW := @csumW + W) as cumulative_W FROM ( SELECT WEEK(s.date) week, SUM(CASE WHEN s.user_id = 50 THEN s.points ELSE 0 END) AS A, SUM(CASE WHEN s.user_id = 51 THEN s.points ELSE 0 END) AS M, SUM(CASE WHEN s.user_id = 52 THEN s.points ELSE 0 END) AS E, SUM(CASE WHEN s.user_id = 53 THEN s.points ELSE 0 END) AS W FROM users u JOIN scores s ON u.user_id = s.user_id JOIN league l ON l.league_id = s.league_id AND and l.league_name = 'Sunday League' WHERE year(s.date) = YEAR(sysdate()) GROUP BY s.date ORDER BY s.date ASC ) PTS JOIN ( SELECT @csumA:=0, @csumM:=0, @csumE := 0, @csumW:=0 ) INIT;
    2 points
This leaderboard is set to New York/GMT-04:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.