工作中常用sql函数
场景:用订单号去订单表查计划还款时间
步骤:
1. 将订单号按算法取整做为分表号:tb_repay_plan_02
2. 将计划还款时间戳转为日期
3. 用订单号查询该笔还款计划,直观的转化后的计划还款时间
取整:
select floor(726802646817144832/10000%16);
它的结果是2,分表号十位补零tb_repay_plan_02
将时间转为时间戳
select unix_timestamp(‘2020-04-09’);
from_unixtime(‘1588003200’);
将时间戳转为时间from_unixtime(字段名)
将时间戳的列转为时间做为表的一列:
select from_unixtime(plan_repay_date),t.plan_repay_date as bb,t.* from hfax_ldp.tb_repay_plan_02 t where loan_id=‘726802646817144832’;