select left(order_date, 7) as month, count( order_id ) as order_count, count(distinct customer_id) as customer_count from Orders where invoice>20 group by left(order_date, 7)
@dornalanavya17226 ай бұрын
great explanation sir thank you so much
@the_fury078 ай бұрын
we also can use date_format(order_date, yyyy-mm) to group by
@aakashbhandari9761 Жыл бұрын
Thanks a lot for this playlist❤
@sukumar-m4t7 күн бұрын
LeetCode prime Q/A
@mlvprasadofficial2 жыл бұрын
30
@prathamsarraf69995 ай бұрын
CREATE TABLE Orders ( order_id INT, order_date DATE, customer_id INT, invoice INT ); INSERT INTO Orders (order_id, order_date, customer_id, invoice) VALUES (1, '2020-09-15', 1, 30), (2, '2020-09-17', 2, 90), (3, '2020-10-06', 3, 20), (4, '2020-10-20', 3, 21), (5, '2020-11-10', 1, 10), (6, '2020-11-21', 2, 15), (7, '2020-12-01', 4, 55), (8, '2020-12-03', 4, 77), (9, '2021-01-07', 3, 31), (10, '2021-01-15', 2, 20); SELECT SUBSTRING(order_date,1,7) AS month ,COUNT(*) AS order_count,COUNT(DISTINCT customer_id) AS customer_count FROM Orders WHERE invoice>20 GROUP BY SUBSTRING(order_date,1,7)