From eb7bfd31cfd95ae5eac55a3b1b874db55c7b82d9 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 8 Dec 2023 16:12:11 +0100 Subject: [PATCH] added example files for aggregators and random --- tasks/aggregators.sql | 12 ++++++++++++ tasks/pricePerSqm.sql | 3 +++ tasks/rands.sql | 1 + 3 files changed, 16 insertions(+) create mode 100644 tasks/aggregators.sql create mode 100644 tasks/pricePerSqm.sql create mode 100644 tasks/rands.sql diff --git a/tasks/aggregators.sql b/tasks/aggregators.sql new file mode 100644 index 0000000..298abf9 --- /dev/null +++ b/tasks/aggregators.sql @@ -0,0 +1,12 @@ +USE tutorial; + +SELECT count(annualSalaryGrossEUR_Amount) FROM Employee; +SELECT sum(annualSalaryGrossEUR_Amount) FROM Employee; +SELECT avg(annualSalaryGrossEUR_Amount) FROM Employee; + +SELECT Department.name, round(avg(annualSalaryGrossEUR_Amount), 2) AS salary + FROM Employee + LEFT JOIN Department ON Employee.departmentId = Department.id + GROUP BY departmentId + HAVING salary > 48000 + ORDER BY salary DESC; \ No newline at end of file diff --git a/tasks/pricePerSqm.sql b/tasks/pricePerSqm.sql new file mode 100644 index 0000000..b46ab59 --- /dev/null +++ b/tasks/pricePerSqm.sql @@ -0,0 +1,3 @@ +USE tutorial; + +SELECT round(EUR_rentalAmount / Room.M2_area, 2) AS 'price per m²' FROM Room; \ No newline at end of file diff --git a/tasks/rands.sql b/tasks/rands.sql new file mode 100644 index 0000000..07babcc --- /dev/null +++ b/tasks/rands.sql @@ -0,0 +1 @@ +SELECT floor(rand() * (8.0 - 2.0) + 2.0); \ No newline at end of file