Search code examples
sqlhiveqliksense

Find Maximum from the column in HIVE


I am very much new to HIVE. I am working with QLiksense and HIVE. I have a table with year,month,day. I loaded the table and concatenated as,

Load year&''&month''&day as concatdate;
SQL select * from HIVE. 'abc'. 'def'; 

Load ...
..
(the other fields)
..
..
SQL select * from HIVE. 'abc'. 'def';

Now I want to find the maximum of the concatdate and retrieve those rows alone in HIVE. The year month and day is string type.

Please do help.


Solution

  • One method uses a subquery:

    select h.*
    from hive.abc.def h
    where h.concatdate = (select max(h2.concatdate) from hive.abc.def h2);