Skip to content

Commit 816ecc7

Browse files
committed
Upload 149
1 parent d5c1626 commit 816ecc7

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ The problems and both submitted and site solutions are documented in individual
181181
| 146 | [Department Highest Salary](https://leetcode.com/problems/department-highest-salary/description/) | [Solution](solutions/146_department_highest_salary.md) | LeetCode | Medium | |
182182
| 147 | [Customer Placing the Largest Number of Orders](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/description/) | [Solution](solutions/147_customer_placing_the_largest_number_of_orders.md) | LeetCode | Easy | `ORDER BY` w/ Aggregate Function |
183183
| 148 | [Swap Salary](https://leetcode.com/problems/swap-salary/description/) | [Solution](solutions/148_swap_salary.md) | LeetCode | Easy | |
184+
| 149 | [Sales Person](https://leetcode.com/problems/sales-person/description/) | [Solution](solutions/149_sales_person.md) | LeetCode | Easy | |
184185
<!-- Index End - WARNING: Do not delete or modify this markdown comment. -->
185186

186187
## Author(s)

solutions/149_sales_person.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SQL Everyday \#149
2+
3+
## Sales Person
4+
5+
Site: LeetCode\
6+
Difficulty per Site: Easy
7+
8+
## Problem
9+
10+
Write a solution to find the names of all the salespersons who did not have any orders related to the company with the name *"RED"*.
11+
12+
Return the result table in *any order*. [[Full Description](https://leetcode.com/problems/sales-person/description/)]
13+
14+
## Submitted Solution
15+
16+
```sql
17+
-- Submitted Solution
18+
WITH cte1 AS (
19+
SELECT
20+
*
21+
FROM Orders AS o
22+
JOIN Company AS c on o.com_id = c.com_id
23+
),
24+
cte2 AS (
25+
SELECT
26+
p.name
27+
,COUNT(*) FILTER (WHERE c.name = 'RED') AS ccount
28+
FROM SalesPerson AS p
29+
LEFT JOIN cte1 AS c ON p.sales_id = c.sales_id
30+
GROUP BY p.name
31+
)
32+
SELECT
33+
name
34+
FROM cte2
35+
WHERE ccount = 0
36+
;
37+
```
38+
39+
## Site Solution
40+
41+
```sql
42+
-- LeetCode Solution
43+
-- TBD
44+
```
45+
46+
## Notes
47+
48+
TBD
49+
50+
## NB
51+
52+
TBD
53+
54+
Go to [Index](../?tab=readme-ov-file#index)\
55+
Go to [Overview](../?tab=readme-ov-file)

0 commit comments

Comments
 (0)