File tree Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 11<!-- markdownlint-disable MD041 -->
22[ ![ eevveerryyddaayy release] ( https://img.shields.io/badge/eevveerryyddaayy-v1.3.0-blue.svg )] ( https://github.com/ggeerraarrdd/eevveerryyddaayy/ )
3- [ ![ Solved] ( https://img.shields.io/badge/solved-188 -green.svg )] ( #index )
3+ [ ![ Solved] ( https://img.shields.io/badge/solved-189 -green.svg )] ( #index )
44<!-- markdownlint-enable MD041 -->
55
66# SQL Everyday
@@ -222,6 +222,7 @@ Because this project necessitated a framework to enable consistent daily practic
222222| 186 | [ Sales Analysis II] ( https://leetcode.com/problems/sales-analysis-ii/description/ ) | [ Solution] ( solutions/186_sales_analysis_ii.md ) | LeetCode | Easy | ` STRING_AGG ` vs ` GROUP_CONCAT ` |
223223| 187 | [ Sales Analysis III] ( https://leetcode.com/problems/sales-analysis-iii/description/ ) | [ Solution] ( solutions/187_sales_analysis_iii.md ) | LeetCode | Easy | ` HAVING ` |
224224| 188 | [ The Winner University] ( https://leetcode.com/problems/the-winner-university/description/ ) | [ Solution] ( solutions/188_the_winner_university.md ) | LeetCode | Easy | |
225+ | 189 | [ Unique Orders and Customers Per Month] ( https://leetcode.com/problems/unique-orders-and-customers-per-month/description/ ) | [ Solution] ( solutions/189_unique_orders_and_customers_per_month.md ) | LeetCode | Easy | |
225226<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
226227<!-- - cSpell:enable --->
227228
Original file line number Diff line number Diff line change 1+ # SQL Everyday \# 189
2+
3+ ## Unique Orders and Customers Per Month
4+
5+ Site: LeetCode\
6+ Difficulty per Site: Easy
7+
8+ ## Problem
9+
10+ Write a solution to find the number of ** unique orders** and the number of ** unique customers** with invoices ** > $20** for each ** different month** .
11+
12+ Return the resulting table in ** any order** . [[ Full Description] ( https://leetcode.com/problems/unique-orders-and-customers-per-month/description/ )]
13+
14+ ## Submitted Solution
15+
16+ ``` sql
17+ -- Submitted Solution
18+ SELECT
19+ TO_CHAR(order_date, ' YYYY-MM' ) AS month
20+ ,COUNT (DISTINCT order_id) AS order_count
21+ ,COUNT (DISTINCT customer_id) AS customer_count
22+ FROM Orders
23+ WHERE invoice > 20
24+ GROUP BY month
25+ ;
26+ ```
27+
28+ ## Site Solution
29+
30+ ``` sql
31+ -- LeetCode Solution
32+ -- None
33+
34+ -- Code Author: Yasin
35+ -- https://leetcode.com/problems/unique-orders-and-customers-per-month/solutions/960078/mysql-solution
36+ -- (modified)
37+ SELECT
38+ LEFT(order_date, 7 ) AS month
39+ ,COUNT (DISTINCT order_id) AS order_count
40+ ,COUNT (DISTINCT customer_id) AS customer_count
41+ FROM Orders
42+ WHERE invoice > 20
43+ GROUP BY 1
44+ ;
45+ ```
46+
47+ ## Notes
48+
49+ TBD
50+
51+ ## NB
52+
53+ TBD
54+
55+ Go to [ Index] ( ../?tab=readme-ov-file#index ) \
56+ Go to [ Overview] ( ../?tab=readme-ov-file )
You can’t perform that action at this time.
0 commit comments