I have made a CTE that shows the orderdate sum of the ordered quantity, and its respective cumulative frequency. I have to keep this line "JOIN cte c2 ON c1.orderdate<=c2.orderdate" in this form only and get the correct results. Please tell me what changes are to be made in the code to get the correct result. The code is done in Postgres. Below is the output which I want.
NOTE: No changes have to be made in this line "JOIN cte c2 ON c1.orderdate<=c2.orderdate"
WITH cte AS( SELECT o.orderdate, SUM(od.quantity) AS "totalsum" FROM orders o JOIN orderdetails od ON o.orderid=od.orderid GROUP BY o.orderdate ) SELECT c1.orderdate, c1.totalsum, SUM(c2.totalsum) FROM cte c1 JOIN cte c2 ON c1.orderdate<=c2.orderdate GROUP BY c1.orderdate, c1.totalsum ORDER BY c1.orderdate;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.