Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
12_homework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨鹏
12_homework
Commits
dae96967
Commit
dae96967
authored
Feb 17, 2019
by
yangpengflag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql作业
parents
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
employee.sql
+19
-0
No files found.
employee.sql
0 → 100644
View file @
dae96967
-- 部门工资最高的员工
select
d
.
`Name`
as
'Department'
,
e
.
`Name`
as
'Employee'
,
e
.
Salary
from
employee
e
LEFT
JOIN
department
d
on
e
.
DepartmentId
=
d
.
Id
where
(
e
.
Salary
,
e
.
DepartmentId
)
in
(
select
max
(
Salary
),
DepartmentId
from
Employee
group
by
DepartmentId
);
select
d
.
Name
as
Department
,
e
.
Name
as
Employee
,
e
.
Salary
from
Department
d
,
Employee
e
where
e
.
DepartmentId
=
d
.
Id
and
e
.
Salary
=
(
Select
max
(
Salary
)
from
Employee
where
DepartmentId
=
d
.
Id
);
-- 部门工资前三高的员工
select
d
.
`Name`
as
'Department'
,
e
.
`Name`
as
'Employee'
,
e
.
Salary
from
employee
e
LEFT
JOIN
department
d
on
e
.
DepartmentId
=
d
.
Id
where
3
>
(
SELECT
count
(
*
)
from
employee
e2
where
e2
.
Salary
>
e
.
Salary
and
e
.
DepartmentId
=
e2
.
DepartmentId
)
order
by
e
.
DepartmentId
,
e
.
Salary
desc
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment