From 569f67ed2158afc3eadb78a5e7e197e9a3648607 Mon Sep 17 00:00:00 2001 From: Maksim Eremeev Date: Wed, 2 Oct 2019 15:39:12 +0300 Subject: [PATCH] Problem set 1 solutions added by Maksim Eremeev (#52) * Problem set 1 solutions added * Problem set 1 solutions added * minor --- task1/Eremeev_1_1.sql | 7 +++++++ task1/Eremeev_1_2.sql | 6 ++++++ task1/Eremeev_1_3.sql | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 task1/Eremeev_1_1.sql create mode 100644 task1/Eremeev_1_2.sql create mode 100644 task1/Eremeev_1_3.sql diff --git a/task1/Eremeev_1_1.sql b/task1/Eremeev_1_1.sql new file mode 100644 index 00000000..a61a0d1c --- /dev/null +++ b/task1/Eremeev_1_1.sql @@ -0,0 +1,7 @@ +SELECT + customer_rk, + CASE + WHEN middle_nm LIKE '%А' THEN 'F' + WHEN middle_nm LIKE '%Ч' THEN 'M' + END AS Gender +FROM cd_customers WHERE YEAR(valid_to_dttm) = 5999 diff --git a/task1/Eremeev_1_2.sql b/task1/Eremeev_1_2.sql new file mode 100644 index 00000000..4023de65 --- /dev/null +++ b/task1/Eremeev_1_2.sql @@ -0,0 +1,6 @@ +SELECT + monthly_income_amt +FROM cd_customers +WHERE YEAR(valid_from_dttm) <= 2014 AND YEAR(valid_to_dttm) >= 2014 +ORDER BY monthly_income_amt DESC +LIMIT 10 diff --git a/task1/Eremeev_1_3.sql b/task1/Eremeev_1_3.sql new file mode 100644 index 00000000..6403f558 --- /dev/null +++ b/task1/Eremeev_1_3.sql @@ -0,0 +1,5 @@ +SELECT DISTINCT + CONCAT(FLOOR(YEAR(birth_dt) / 10), '0-е') AS Generation +FROM cd_customers +WHERE YEAR(valid_to_dttm) = 5999 +ORDER BY Generation DESC