我可以这样做:MIN/MAX的字符串?
create table newdata as
select id, min(timestamp) as time_start, max(timestamp) as time_stop
from mydata group by id;
如果timestamp
是一个数字(UTC秒)。
但是,假设它是一个字符串,而不是(YYYYMMDDHH
)。
我可以使用unix_timestamp
,当然,但似乎矫枉过正,因为下一步将是
select time_start, time_stop, count(*)
from newdata group by time_start, time_stop;
,我将不得不再次映射到的字符串。
那么,人们对字符串min
/max
做什么?
SQL使用字母顺序在字符串上支持'min()'/'max()'。 –
Hive支持字符串上的最小/最大值 –