Hive: SELECT AS and GROUP BY

前端 未结 2 1925
情书的邮戳
情书的邮戳 2021-02-06 03:58

I have a Hive Query like

SELECT Year, Month, Day, Hours, Minutes,
           cast((cast(Seconds as int)/15) as int)*15
AS secondMod, Count(*) AS PerCount FROM L         


        
相关标签:
2条回答
  • 2021-02-06 04:00

    Try this:

    SELECT Year, Month, Day, Hours, Minutes, 
    cast((cast(Seconds as int)/15) as int)*15 
    AS secondMod, Count(*) AS PerCount FROM LoggerTable 
     GROUP BY Year, Month, Day, Hours, Minutes, 
       cast((cast(Seconds as int)/15) as int)*15
    ORDER BY PerCount;
    
    0 讨论(0)
  • 2021-02-06 04:09

    In Hive 0.11.0 and later, columns can be specified by position if hive.groupby.orderby.position.alias is set to true. Please confirm if the following query works for you.

    SET hive.groupby.orderby.position.alias=true;
    SELECT Year
           ,Month
           ,Day
           ,Hours
           ,Minutes
           ,cast((cast(Seconds as int)/15) as int)*15 AS secondMod
           ,count(*) AS PerCount 
    FROM LoggerTable 
    GROUP BY 1, 2, 3, 4, 5, 6
    ORDER BY 7;
    
    0 讨论(0)
提交回复
热议问题