Skip to content

Commit 15f535a

Browse files
add 1076
1 parent 38cbcf3 commit 15f535a

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ _If you like this project, please leave me a star._ ★
855855
|1084|[Sales Analysis III](https://leetcode.com/problems/sales-analysis-iii/)|[Solution](../master/database/_1084.sql) | | Easy |
856856
|1083|[Sales Analysis II](https://leetcode.com/problems/sales-analysis-ii/)|[Solution](../master/database/_1083.sql) | | Easy |
857857
|1082|[Sales Analysis I](https://leetcode.com/problems/sales-analysis-i/)|[Solution](../master/database/_1082.sql) | | Easy |
858+
|1076|[Project Employees II](https://leetcode.com/problems/project-employees-ii/)|[Solution](../master/database/_1076.sql) | | Easy |
858859
|1075|[Project Employees I](https://leetcode.com/problems/project-employees-i/)|[Solution](../master/database/_1075.sql) | | Easy |
859860
|1069|[Product Sales Analysis II](https://leetcode.com/problems/product-sales-analysis-ii/)|[Solution](../master/database/_1069.sql) | | Easy |
860861
|1068|[Product Sales Analysis I](https://leetcode.com/problems/product-sales-analysis-i/)|[Solution](../master/database/_1068.sql) | | Easy |

database/_1076.sql

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
--1076. Project Employees II
2+
--
3+
--Table: Project
4+
--
5+
--+-------------+---------+
6+
--| Column Name | Type |
7+
--+-------------+---------+
8+
--| project_id | int |
9+
--| employee_id | int |
10+
--+-------------+---------+
11+
--(project_id, employee_id) is the primary key of this table.
12+
--employee_id is a foreign key to Employee table.
13+
--Table: Employee
14+
--
15+
--+------------------+---------+
16+
--| Column Name | Type |
17+
--+------------------+---------+
18+
--| employee_id | int |
19+
--| name | varchar |
20+
--| experience_years | int |
21+
--+------------------+---------+
22+
--employee_id is the primary key of this table.
23+
--
24+
--
25+
--Write an SQL query that reports all the projects that have the most employees.
26+
--
27+
--The query result format is in the following example:
28+
--
29+
--Project table:
30+
--+-------------+-------------+
31+
--| project_id | employee_id |
32+
--+-------------+-------------+
33+
--| 1 | 1 |
34+
--| 1 | 2 |
35+
--| 1 | 3 |
36+
--| 2 | 1 |
37+
--| 2 | 4 |
38+
--+-------------+-------------+
39+
--
40+
--Employee table:
41+
--+-------------+--------+------------------+
42+
--| employee_id | name | experience_years |
43+
--+-------------+--------+------------------+
44+
--| 1 | Khaled | 3 |
45+
--| 2 | Ali | 2 |
46+
--| 3 | John | 1 |
47+
--| 4 | Doe | 2 |
48+
--+-------------+--------+------------------+
49+
--
50+
--Result table:
51+
--+-------------+
52+
--| project_id |
53+
--+-------------+
54+
--| 1 |
55+
--+-------------+
56+
--The first project has 3 employees while the second one has 2.
57+
58+
--# Write your MySQL query statement below
59+
select project_id from Project
60+
group by project_id
61+
having count(employee_id) =
62+
(
63+
select count(employee_id)
64+
from Project
65+
group by project_id
66+
order by count(employee_id)
67+
desc
68+
limit 1
69+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy