将星期几名称转换为星期几 Vertica

Convert day of week name to day of week number Vertica

可能case表达式是最简单的方法:

(case ? 
    when 'MONDAY' then 1
    when 'TUESDAY' then 2
    when 'WEDNESDAY' then 3
    when 'THURSDAY' then 4
    when 'FRIDAY' then 5
    when 'SATDAY' then 6
    when 'SUNDAY' then 7
 end)

或者数组更简洁:

array_find(?,
           array['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY']
          ) + 1