Skip to content

Commit d39f1ac

Browse files
committedOct 12, 2018
update
1 parent e8ad0e8 commit d39f1ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+663
-28
lines changed
 

‎LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 https://github.com/kamyu104/LeetCode-Solution
3+
Copyright (c) 2018 https://github.com/kamyu104/LeetCode-Solutions
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Time: O(nlogn)
2+
# Space: O(n)
3+
4+
SELECT department_salary.pay_month, department_id,
5+
CASE
6+
WHEN department_avg < company_avg THEN 'lower'
7+
WHEN department_avg > company_avg THEN 'higher'
8+
ELSE 'same'
9+
END AS comparison
10+
FROM
11+
(
12+
SELECT department_id, AVG(amount) AS department_avg, date_format(pay_date, '%Y-%m') AS pay_month
13+
FROM salary JOIN employee ON salary.employee_id = employee.employee_id
14+
GROUP BY department_id, pay_month
15+
) AS department_salary
16+
JOIN
17+
(
18+
SELECT AVG(amount) AS company_avg, date_format(pay_date, '%Y-%m') AS pay_month
19+
FROM salary
20+
GROUP BY date_format(pay_date, '%Y-%m')
21+
) AS company_salary
22+
ON department_salary.pay_month = company_salary.pay_month
23+
;
24+

0 commit comments

Comments
 (0)
Please sign in to comment.