How to remove special chars form string in hive

11,677

Since your cell has strings of format ($ddd.dd).. I would simply replace $ with ''

EX:

SELECT REGEXP_REPLACE(OrderAmount, '\\$', '') 

For counting between range of 100 you can do the following:

SELECT COUNT(*) FROM order GROUP BY floor(float(REGEXP_REPLACE(OrderAmount, '\\$', ''))/100);
Share:
11,677
learner
Author by

learner

Updated on June 04, 2022

Comments

  • learner
    learner almost 2 years

    Hi guys i m completely new to hive ..

    i have amount column in table

    1)i am trying to remove dollar sign from amount but its not working am using reg-ex extract.

    2)and also want count of amount between 0- 99,100-199 and so on.