Skip to content
Advertisement

User Defined Column name in select statement in Hivesql

I need to create user defined column name like below Postgresql query into HiveSql. Could you please help me on this.

SELECT
    COUNT(user_id) as "Total Customers"
FROM 
    customer_profiles
WHERE
    profiled_date BETWEEN '2020-01-01' AND '2020-12-31'

Advertisement

Answer

Use backticks:

SELECT
    COUNT(user_id) as `Total Customers`
FROM 
 ...

But it is not possible to preserve case due to Hive limitation. Resulted column name will be in lower case:

total customers

See this answer: https://stackoverflow.com/a/57183048/2700344

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement