类型转换 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 是不一样的