17,377
社区成员
发帖
与我相关
我的任务
分享
with tab as
(
select 'A' louyu, 'a' shebei, '20110117' gaojing from dual
union all
select 'A', 'a', '20110118' from dual
union all
select 'A', 'a', '20110119' from dual
union all
select 'A', 'b', '20110117' from dual
union all
select 'A', 'b', '20110118' from dual
union all
select 'B', 'a', '20110117' from dual
union all
select 'B', 'b', '20110117' from dual
)
select count(shebei) from tab where to_date(gaojing,'yyyymmdd') between to_date('20110101','yyyymmdd') and to_date('20110119','yyyymmdd') group by louyu
------------------------------------
5
2
--大概是这样
SELECT build_code, Count(device_code) 设备个数
FROM 告警信息表
WHERE alarm_time BETWEEN 起始时间 AND 结束时间
GROUP BY build_code
select count(distinct device_code)
from tablename
where alarm_time between to_date('20110116','yyyymmdd')
and to_date('20110117','yyyymmdd')
SELECT build_code, Count(device_code) 设备个数
FROM 告警信息表
WHERE alarm_time BETWEEN 起始时间 AND 结束时间
GROUP BY build_code