年月分組
select to_char(collection_time ,"yyyy-mm") AS date, cast(SUM(a.stage_value)as DOUBLE) as stage_value from TABLE GROUP BY `date`
年月日分組
select to_char(collection_time ,"yyyy-mm-dd") AS date, SUM(a.stage_value)as DOUBLE) as stage_value from TABLE GROUP BY `date`
年月日小時分組
select CONCAT(to_char(a.collection_time ,"yyyy-mm-dd"),' ',to_char(a.collection_time ,"HH24"))AS date, cast(SUM(a.stage_value)as DOUBLE) as stage_value from TABLE GROUP BY `date`
to_char(yyyy-mm-dd hh) 會有問題。所以用年月日 加24小時制兩個字符串合并成一個時間。