Skip to content

Tag: vertica

REGEXP_SUBSTR to extract a substring from Vertical SQL

I am trying to run the below query to get a substring from a string but it gives wrong result. I am not sure how to use the regex since the regex I am using works well with PCRE. I am expecting to get ndehqb-a3g4-a10 in this case but it prints the original string itself. The ask is to get

Median of three columns (for each row) in Vertica SQL

My table looks like this: Product Length Width Height A 34 22 10 B 40 2 12 I would like to get the longest, second longest and third longest side for each product. For the longest and third longest it was easy, I did it like with GREATEST() and LEAST(). For the second longest for the moment I am doing

Convert day of week name to day of week number Vertica

With this way – SELECT TO_CHAR(NOW(), ‘DAY’); I can get a day of week name(E.G. MONDAY). With SELECT dayofweek(NOW()); I can get the number of the day of week. (E.G 1) QUESTION: How to convert day of week name to day of week number. (E.G MONDAY -> 1) SMTH like TO_NUMBER(‘MONDAY&#821…