-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cab8c84
commit 9305f7c
Showing
7 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT doctor.name, ( ( 1 * 150 ) + 1 ) + ( ( 2 * 150 ) + 15 ) FROM attendances | ||
JOIN doctors ON doctors.id = attendances.id_doctor | ||
JOIN work_shifts ON work_shifts.id = attendances.id_work_shift | ||
GROUP BY attendances.id | ||
ORDER BY doctors.name; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DROP TABLE attendances; | ||
DROP TABLE work_shifts; | ||
DROP TABLE doctors; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
https://judge.beecrowd.com/en/problems/view/2994 | ||
|
||
# How much does a Doctor earn? | ||
|
||
You work in the IT sector for a hospital and need to calculate the payment | ||
revenue from each of the doctors. Each doctor earns 150$ per hour plus a | ||
percentage that depends on the work shift. For example, the doctor Wellington | ||
worked 1 hour in the day shift, and 2 hours in the night shift, therefore his | ||
weekly salary will be: ( ( 1 * 150 ) + 1% ) + ( ( 2 * 150 ) + 15% ) = 496.5. | ||
Furthermore, you can use the function ROUND(value,1) to show the salary with 1 | ||
decimal place e order the result from the highest to lowest salary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- URI Online Judge SQL | ||
--- Copyright URI Online Judge | ||
--- www.urionlinejudge.com.br | ||
--- Problem 2994 | ||
|
||
CREATE TABLE doctors ( | ||
id integer PRIMARY KEY, | ||
name varchar(50) | ||
); | ||
|
||
GRANT SELECT ON doctors TO sql_user; | ||
|
||
CREATE TABLE work_shifts ( | ||
id integer PRIMARY KEY, | ||
name varchar(50), | ||
bonus numeric | ||
); | ||
|
||
GRANT SELECT ON work_shifts TO sql_user; | ||
|
||
CREATE TABLE attendances ( | ||
id integer PRIMARY KEY, | ||
id_doctor integer, | ||
hours integer, | ||
id_work_shift integer, | ||
FOREIGN KEY (id_doctor) REFERENCES doctors(id), | ||
FOREIGN KEY (id_work_shift) REFERENCES work_shifts(id) | ||
); | ||
|
||
GRANT SELECT ON attendances TO sql_user; | ||
|
||
insert into doctors (id,name) values | ||
(1,'Arlino'), | ||
(2,'Tiago'), | ||
(3,'Amanda'), | ||
(4,'Wellington'); | ||
|
||
insert into work_shifts (id,name,bonus) values | ||
(1,'nocturnal',15), | ||
(2,'afternoon',2), | ||
(3,'day',1); | ||
|
||
insert into attendances (id, id_doctor, hours, id_work_shift) values | ||
(1,1,5,1), | ||
(2,3,2,1), | ||
(3,3,3,2), | ||
(4,2,2,3), | ||
(5,1,5,3), | ||
(6,4,1,3), | ||
(7,4,2,1), | ||
(8,3,2,2), | ||
(9,2,4,2); | ||
|
||
/* Execute this query to drop the tables */ | ||
-- DROP TABLE attendances; | ||
-- DROP TABLE work_shifts; | ||
-- DROP TABLE doctors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sql |