AC solution without join

  • 0
    SELECT id, 
           (SELECT Sum(salary) 
            FROM   employee 
            WHERE  month <= e.month 
                   AND month >= e.month - 2 
                   AND id = salary 
    FROM   employee e 
    WHERE  ( id, month ) NOT IN (SELECT id, 
                                        Max(month) AS month 
                                 FROM   employee 
                                 GROUP  BY id) 
    ORDER  BY id ASC, 
              month DESC; 

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.