查询出来的数据 按天分组,数据库只有一个时间字段 是 时间戳
selectdistinct(dev_id),count(1)fromt_report_visit_201211whererecord_datetime>13531680...
select distinct(dev_id) ,count(1) from t_report_visit_201211 where record_datetime >1353168000 group by
展开
展开全部
思路:需将时间戳转成date格式,再用trunc()函数,得到日期部分,最好按日期和dev_id分组
SQL如下:
select trunc(to_date('19700101','YYYYMMDD')+t.record_datetime/86400+to_number(substr(tz_offset(sessiontimezone),1,3))/24,'dd') "日期",
distinct(dev_id),count(1)
from t_report_visit_201211 t
where t.record_datetime >1353168000
group by trunc(to_date('19700101','YYYYMMDD')+t.record_datetime/86400+to_number(substr(tz_offset(sessiontimezone),1,3))/24,'dd'),dev_id;
SQL如下:
select trunc(to_date('19700101','YYYYMMDD')+t.record_datetime/86400+to_number(substr(tz_offset(sessiontimezone),1,3))/24,'dd') "日期",
distinct(dev_id),count(1)
from t_report_visit_201211 t
where t.record_datetime >1353168000
group by trunc(to_date('19700101','YYYYMMDD')+t.record_datetime/86400+to_number(substr(tz_offset(sessiontimezone),1,3))/24,'dd'),dev_id;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |