Consider i have hive table with columns script_name, start_time, end_time, duration. Start time, end time and duration are in the format of hh:mm:ss. My requirement is to find the average time of these columns for last 7 days and put into a file.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
Convert to unix_timestamp, sum, divide by 3, convert to bigint and convert back to HH:mm:ss:
Result:
See test here: http://demo.gethue.com/hue/editor?editor=285484&type=hive
For single column:
Convert to unix timestamp, calculate average in seconds, convert to bigint (average is double, there will be some fraction of second precision loss), and finally convert it back to the string time format:
Result:
See test here: http://demo.gethue.com/hue/editor?editor=285464&type=hive