Search code examples
hivehiveql

Hive words starting with a vowel


I have a table tbl_2016 with columns col1 and col2. I want to obtain the sum of col1 where col2 starts with a vowel. I have tried the following code but I am afraid that Hive understands it as starting with “AEIOU” and not “A” or “E” or “I” or “O” or “U”:

select SUM(col1) as Total_col1 from tbl_2016 WHERE col2 LIKE "[AEIOU]%";

Solution

  • Try using RLIKE to match regex:

    select SUM(col1) as Total_col1 from tbl_2016 WHERE col2 RLIKE '^[AEIOU]';