欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

使用hive过程中遇到的小问题

程序员文章站 2022-12-18 20:59:48
类型转换 cast(t.delay_days_v2 AS int) SELECT cast(t.delay_days_v2 AS int) AS delay_days_v2,...

类型转换 cast(t.delay_days_v2 AS int)

SELECT cast(t.delay_days_v2 AS int) AS delay_days_v2,
       t.product_type,
       count(DISTINCT t.order_id) AS count_order_id,
       sum(t.principal -t.repaid_principal) AS sum_principal
FROM dm.dm_order_instalment_info AS t
WHERE t.instalment_status = "I"
  AND cast(t.delay_days_v2 AS int) >= -15
  AND cast(t.delay_days_v2 AS int) <=80
GROUP BY t.delay_days_v2,
         t.product_type
ORDER BY delay_days_v2

日期转换,将时间戳转换为2018-03-08的格式

from_unixtime(cast(t.billing_date as BIGINT),'yyyy-MM-dd')

sort by 和order by 是不一样的