PG数据库,时间戳转换
将毫秒/秒转成格式化后的时间
select to_char(to_timestamp(time),'yyyy-MM-dd HH24-MI-SS') as time from tablename;
#统计每个月的记录数
select to_char(to_timestamp(time),'yyyy-MM') as time ,count(1) from tablename group by time;
PG数据库,时间戳转换
将毫秒/秒转成格式化后的时间
select to_char(to_timestamp(time),'yyyy-MM-dd HH24-MI-SS') as time from tablename;
#统计每个月的记录数
select to_char(to_timestamp(time),'yyyy-MM') as time ,count(1) from tablename group by time;