1. 程式人生 > >Hive計算數據的時間差

Hive計算數據的時間差

rom 時間差 nbsp ble sele tab ive lec table

數據倉庫如何計算兩者時間差了:

TD_TABLE:

pid time

123 00:01

123 00:02

123 00:03

123 00:04

select row_number() over(partition by time desc) as row_num from TD_TABLE

select t1.time-t2.time,t1.pid from TD_TABLE t1

join

TD_TABLE t2

on t1.pid=t2.pid and t1.row_num=t2.row_num-1

Hive計算數據的時間差