· 5 years ago · May 02, 2020, 10:46 PM
1CREATE TABLE IF NOT EXISTS `CALC_TABLE` as (
2 SELECT tr.bib,
3 tr.name,
4 tr.official_time,
5 ((cast(substr(official_time, 1, 2) as int) * 3600) +
6 (cast(substr(official_time, 4, 2) as int) * 60) +
7 (cast(substr(official_time, 7, 2) as int))) as time_in_sec,
8 tr.age,
9 (case
10 when tr.age < 11 then '0-10'
11 when tr.age >= 11 and tr.age <= 20 then '11-20'
12 when tr.age > 20 and tr.age <= 30 then '21-30'
13 when tr.age > 30 and tr.age <= 40 then '31-40'
14 when tr.age > 40 and tr.age <= 50 then '41-50'
15 when tr.age > 40 and tr.age <= 45 then '51-60'
16 when tr.age > 45 and tr.age <= 50 then '61-70'
17 when tr.age > 50 and tr.age <= 55 then '71-80'
18 when tr.age > 55 and tr.age <= 60 then '81-90'
19 when tr.age > 60 and tr.age <= 65 then '91-100'
20 end
21 ) as age_scope
22 from TEMP_RESULTS AS tr