diff --git a/solutions/beecrowd/2994/2994.sql b/solutions/beecrowd/2994/2994.sql new file mode 100644 index 00000000..711dde3a --- /dev/null +++ b/solutions/beecrowd/2994/2994.sql @@ -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; \ No newline at end of file diff --git a/solutions/beecrowd/2994/WRONG b/solutions/beecrowd/2994/WRONG new file mode 100644 index 00000000..e69de29b diff --git a/solutions/beecrowd/2994/drop-table.sql b/solutions/beecrowd/2994/drop-table.sql new file mode 100644 index 00000000..878cf911 --- /dev/null +++ b/solutions/beecrowd/2994/drop-table.sql @@ -0,0 +1,3 @@ +DROP TABLE attendances; +DROP TABLE work_shifts; +DROP TABLE doctors; \ No newline at end of file diff --git a/solutions/beecrowd/2994/out.txt b/solutions/beecrowd/2994/out.txt new file mode 100644 index 00000000..e69de29b diff --git a/solutions/beecrowd/2994/problem.md b/solutions/beecrowd/2994/problem.md new file mode 100644 index 00000000..1280ffd0 --- /dev/null +++ b/solutions/beecrowd/2994/problem.md @@ -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. diff --git a/solutions/beecrowd/2994/schema.sql b/solutions/beecrowd/2994/schema.sql new file mode 100644 index 00000000..e9edbeee --- /dev/null +++ b/solutions/beecrowd/2994/schema.sql @@ -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; diff --git a/solutions/beecrowd/2994/tags.txt b/solutions/beecrowd/2994/tags.txt new file mode 100644 index 00000000..d5ce2f2b --- /dev/null +++ b/solutions/beecrowd/2994/tags.txt @@ -0,0 +1 @@ +sql