leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1321.sql (411B)


      1 SELECT  a.visited_on,
      2         SUM(b.day_sum) AS amount,
      3         ROUND(AVG(b.day_sum), 2) AS average_amount
      4 FROM
      5   (SELECT visited_on, SUM(amount) AS day_sum FROM Customer GROUP BY visited_on ) a,
      6   (SELECT visited_on, SUM(amount) AS day_sum FROM Customer GROUP BY visited_on ) b
      7 WHERE DATEDIFF(a.visited_on, b.visited_on) BETWEEN 0 AND 6
      8 GROUP BY a.visited_on
      9 HAVING COUNT(b.visited_on) = 7
     10 ORDER BY visited_on