From 76b9a525d946e9705d3eacb95f30402cc40eeb27 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Thu, 3 Oct 2019 20:39:14 +0300 Subject: [PATCH] Add Kholodov solutions (dated Oct 2 10:43) (#55) --- task1/Kholodov_1_1.sql | 7 +++++++ task1/Kholodov_1_2.sql | 5 +++++ task1/Kholodov_1_3.sql | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 task1/Kholodov_1_1.sql create mode 100644 task1/Kholodov_1_2.sql create mode 100644 task1/Kholodov_1_3.sql diff --git a/task1/Kholodov_1_1.sql b/task1/Kholodov_1_1.sql new file mode 100644 index 00000000..d480ccff --- /dev/null +++ b/task1/Kholodov_1_1.sql @@ -0,0 +1,7 @@ +SELECT customer_rk, + (CASE + WHEN middle_nm LIKE '%ИЧ' THEN 'M' + WHEN middle_nm LIKE '%А' THEN 'F' + END) AS gender +FROM cd_customers +WHERE valid_to_dttm = '5999-01-01' \ No newline at end of file diff --git a/task1/Kholodov_1_2.sql b/task1/Kholodov_1_2.sql new file mode 100644 index 00000000..5cc0b740 --- /dev/null +++ b/task1/Kholodov_1_2.sql @@ -0,0 +1,5 @@ +SELECT monthly_income_amt +FROM cd_customers +WHERE valid_to_dttm >= '2014.01.01' AND valid_from_dttm < '2015.01.01' +ORDER BY monthly_income_amt DESC +LIMIT 10; \ No newline at end of file diff --git a/task1/Kholodov_1_3.sql b/task1/Kholodov_1_3.sql new file mode 100644 index 00000000..ab421a1d --- /dev/null +++ b/task1/Kholodov_1_3.sql @@ -0,0 +1,5 @@ +SELECT DISTINCT + CONCAT(SUBSTRING(birth_dt, 1, 3), '0-e') as generation +FROM cd_customers +WHERE valid_to_dttm = '5999-01-01' +ORDER BY generation DESC; \ No newline at end of file