You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.3 KiB
SQL

DROP VIEW IF EXISTS all_projects;
DROP TABLE IF EXISTS all_projects;
#todo we have to find out how to generate this from the info on tablemetadata
CREATE TABLE all_projects AS
SELECT *
FROM CLT2019
UNION
SELECT *
FROM CLT2020
UNION
SELECT *
FROM CLT2021
UNION
SELECT *
FROM CLT2022
UNION
SELECT *
FROM RDU2019
UNION
SELECT *
FROM RDU2020
UNION
SELECT *
FROM RDU2021
UNION
SELECT *
FROM RDU2022
UNION
SELECT *
FROM ENV2020
UNION
SELECT *
FROM ENV2021
UNION
SELECT *
FROM ENV2022
UNION
SELECT *
FROM SRV2020
UNION
SELECT *
FROM SRV2021;
CREATE UNIQUE INDEX ref_num ON all_projects (refnum);
CREATE INDEX project_flavor ON all_projects (proj_type);
UPDATE all_projects
SET description = TRIM(BOTH ' ' FROM description)
WHERE description RLIKE '^ '
OR description RLIKE ' $';
UPDATE all_projects
SET description = 'Soil/Footings'
WHERE description IN
(
'Soil/Footings - Revisit #1',
'Soils/Footings',
'Soils/Footings - Revisit #1',
'Soils/Footings - Revisit #1'
);
UPDATE all_projects
SET description = 'Framing Items'
WHERE description IN
(
'Framing Item'
);
UPDATE all_projects
SET description = '3rd Party Footing Inspection'
WHERE description IN
(
'3rd Party Footing Preparation Inspection'
'3rd Party Footing Preparation Inspection - Revisit #1'
);