Skip to content

Commit 6ef6ddd

Browse files
committed
Adding Jars
1 parent dad331d commit 6ef6ddd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

medium/1532. The Most Recent Three Orders.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ ORDER BY c.name,c.customer_id,r.order_date DESC;
1111

1212
---------------Without Window function---------------
1313

14-
SELECT o1.customer_id,o1.order_date,COUNT(*)
14+
SELECT o1.customer_id,o1.order_date,COUNT(o2.order_date)
1515
FROM orders_1532 o1
1616
INNER JOIN orders_1532 o2 ON o1.customer_id=o2.customer_id AND o1.order_date<=o2.order_date
1717
GROUP BY o1.customer_id,o1.order_date
18-
HAVING COUNT(*)<=3
18+
HAVING COUNT(o2.order_date)<=3
1919
ORDER BY 1,2 DESC;
2020

2121
-- Main logic is over now we only need to apply 2 joins to bring other columns.

0 commit comments

Comments
 (0)