postgres数据库中获取当前日期、周几,还有列转行和hive中获取当前日期、string转成map、列转行的代码

--postgresSQL写法 需求都是同一roadid下,求每15分钟的均速km/h

 create table if not exists avg_speed_week_day0 as (
 		select c.roadid,c.week_day,
	
		max(case when cast(btrim(c.times,'h')as int)  = 000  then c.avg_speed else 0  end ) as "h0000", -- 00
		max(case when cast(btrim(c.times,'h')as int)  = 015  then c.avg_speed else 0  end ) as "h0015",
		max(case when cast(btrim(c.times,'h')as int)  = 030  then c.avg_speed else 0  end ) as "h0030",
		max(case when cast(btrim(c.times,'h')as int)  = 045  then c.avg_speed else 0  end ) as "h0045"
        	from 
				(select b.roadid,b.week_day,b.times, 
						round((sum(b.speed)/count(*)) * 3.6) as avg_speed
				from

						(select a.roadid,a.speed,a.week_day,a.utc,
								case when minute=0 
									then concat('h',hour,'00')
									else concat('h',hour,minute*15)
								end times
						from
								(select roadid,speed,utc,
						
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值