【问题标题】:Count on particular partitions for particular month in hive计算 hive 中特定月份的特定分区
【发布时间】:2017-03-22 01:19:39
【问题描述】:

我有一个用 table_date 分区的 hive 表。我想获取特定月份和特定年份的特定日期的单个分区计数。

当我运行以下查询时,我得到一个整月的计数,但我希望它作为单独的一天。

select count(*) from table where month(table_date)=1 and year(table _date)=2016

【问题讨论】:

  • 您的表是在table_date 还是year(table_date)month(table_date)day(table_date) 上分区的?

标签: sql hive


【解决方案1】:

如果它是按日期分区的,我希望它可以工作:

select table_date, count(*)
from table
where table_date >= '2016-01-01' and table_date < '2016-02-01'
group by table_date;

【讨论】:

    【解决方案2】:
    select table_date, count(*)
    from table
    where table_date between '2016-01-01' and '2016-02-01'
    group by table_date;
    

    【讨论】:

      猜你喜欢
      • 2021-11-25
      • 2011-04-08
      • 2015-04-13
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      相关资源
      最近更新 更多