From 5453cc0c312e41f7b510037ce12adefc588d84e0 Mon Sep 17 00:00:00 2001 From: dtookey Date: Wed, 20 Apr 2022 11:15:43 -0400 Subject: [PATCH] Revert "removed technician classification since we can get that table from google sheets" This reverts commit e3a13374db52f25e34d72912dd89105d9f7049b8. --- src/sql/0-run-first/1-sanitize_init.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sql/0-run-first/1-sanitize_init.sql b/src/sql/0-run-first/1-sanitize_init.sql index 05724b3..194bfe3 100644 --- a/src/sql/0-run-first/1-sanitize_init.sql +++ b/src/sql/0-run-first/1-sanitize_init.sql @@ -33,3 +33,17 @@ ALTER TABLE project_lifecycle CREATE OR REPLACE INDEX lifecycle_timestamp on project_lifecycle (timestamp); CREATE OR REPLACE INDEX lifecycle_newval on project_lifecycle (new_value); + +######### technician categories ############## + +CREATE OR REPLACE TABLE technician_category AS +SELECT DISTINCT users.email, + CONCAT(SUBSTR(ap.refnum, 1, 3), ' - ', + IF(ap.proj_type = 'Warranty', 'Structural', ap.proj_type)) AS flavor, + count(email) AS count +FROM users + INNER JOIN dispatch d ON users.pkey = d.dispatched_to + INNER JOIN all_projects ap ON d.project_fkey = ap.refnum +#where date_dispatched between NOW() - INTERVAL 180 DAY AND NOW() +GROUP BY flavor, email +ORDER BY count DESC;