I want week number from different columns of Year, Month & Day in same table of Hive QL. IF you can give logic on SQL, that's also fine.
Asked
Active
Viewed 55 times
-3
-
1Please provide sample data and expected results. – GMB May 01 '20 at 00:32
-
Please provide sample data, the code you are running, and explain what you mean. – Gordon Linoff May 01 '20 at 00:32
-
I have three columns in tables that is Year, Month & Day. Now I want a temp column which will give me week number So, I can do group by using that temp week number coumn. – Sanskar Singh May 01 '20 at 00:51
-
Year Month Day 2020 4 5 2020 4 7 2020 5 1 2020 5 3 Year Month Day Week 2020 4 5 1 2020 4 7 2 2020 5 1 3 2020 5 3 4 – Sanskar Singh May 01 '20 at 00:54
1 Answers
0
Concatenate the date, month and year into a proper date format and apply weekofyear().
Select weekofyear(cast(concat(year,"-",month,"-",date) as date)) from tablename.
Please note that I have used cast to convert the concatenated string into date.Howver, you might need to use different method based on your date format. Please refer to the below answer on handling string conversion to date formats.

Pari Sairam Mohan
- 421
- 1
- 4
- 11
-
-
I'm getting an error- " Invalid table alias or column reference 'date' " – Sanskar Singh May 01 '20 at 01:13
-