建筑数据预处理脚本

--202.98.194.182:1521/ocp11g datasource/datasource

--1.统计各单位人数
select
fsocial_uuid,
fsocial_name,
count(FSocPerson_UUID) as Fscial_numOfPeople
from View_BD_SocialPerson
group by fsocial_uuid,fsocial_name
order by Fscial_numOfPeople desc
;

--2.统计各单位参加培训人数;
select
fsocial_uuid,
fsocial_name,
count(FPerson_UUID) as TrainedPeople
from View_BS_PersonTrainTaskDtl
group by fsocial_uuid,fsocial_name
order by TrainedPeople desc
;

--3.统计各单位培训通过率
select
fsocial_uuid,
fsocial_name,
round(count(case when Fis_Finish=‘1‘ then 1 else null end)/count(Fis_Finish), 4)*100||‘%‘ as passRate
from View_BS_PersonTrainTaskDtl
group by fsocial_uuid, fsocial_name
order by passRate desc
;

--4.统计各单位物联网设备总数
select
fsocial_uuid,
fsocial_name,
count(Fdevice_UUID) as deviceNum
from View_BD_DeviceInfo
group by fsocial_uuid,fsocial_name
order by deviceNum desc
;

--5.统计各单位物联网损坏数
select
fsocial_uuid,
fsocial_name,
count(Fdevice_UUID) as deviceFailureNum
from View_BD_DeviceInfo
where FStatus=‘02‘
group by fsocial_uuid,fsocial_name
order by deviceFailureNum desc
;

--select fsocial_uuid,fsocial_name from View_BD_DeviceInfo where FStatus=‘02‘ group by fsocial_uuid,fsocial_name;

--6.统计各单位设备故障率
select
fsocial_uuid,
fsocial_name,
round(COUNT(case when FStatus=‘02‘ then 1 else null end)/COUNT(c.FDEVICE_UUID), 4)*100||‘%‘ as deviceFailureRate
from View_BD_DeviceInfo c
group by fsocial_uuid,fsocial_name
order by deviceFailureRate desc
;

select
fsocial_uuid,
fsocial_name,
to_char(round(COUNT(case when FStatus=‘02‘ then 1 else null end)/COUNT(c.FDEVICE_UUID), 4)*100,‘fm990.00‘)||‘%‘ as deviceFailureRate
from View_BD_DeviceInfo c
group by fsocial_uuid,fsocial_name
order by deviceFailureRate desc
;

--遇到的问题:请问sql显示百分比小数点的问题 比如我select round(a1/a2*100,2)||‘%‘ from table的时候 如果a1/a2=0.005的话,就会显示 .5%
--解决办法
select to_char(round(a1/a2*100,2),‘fm999990.00‘)||‘%‘ from table
--其中fm表示去掉空格, 999990.00分别代表整数位数和小数位数是几位

--7.统计各单位设备启用率
select
fsocial_uuid,
fsocial_name,
round(COUNT(case when Fis_Active=‘1‘ then 1 else null end)/COUNT(c.Fis_Active), 4)*100||‘%‘ as deviceUsedNum
from View_BD_DeviceInfo c
group by fsocial_uuid,fsocial_name
order by deviceUsedNum desc
;

--8.统计各单位设备平均报警数
select
fsocial_uuid,
fsocial_name,
round(count(case when Fis_Alarm=‘1‘ then 1 else null end)/count(c.Fis_Alarm), 4)*100||‘%‘ as alrmPerDevice
from View_MN_DeviceMonitorRec c
group by fsocial_uuid, fsocial_name
order by alrmPerDevice desc
;

--9.统计各单位巡查数量
select
fsocial_uuid,
fsocial_name,
count(FPatrolBusDtl_UUID) as numOfPatrol
from View_bs_PatrolBusDtl
group by fsocial_uuid,fsocial_name
order by numOfPatrol desc
;

--10.View_BD_DeviceInfo和View_MN_DeviceMonitorRec inner join , 求交集
--fsocial_uuid fsocial_name deviceNum deviceFailureNum deviceFailureRate deviceUsedNum alrmPerDevice
--select * from A inner join B on A.field1=B.field2;
select
a.fsocial_uuid,
a.fsocial_name,
count(a.Fdevice_UUID) as deviceNum,
count(case when a.FStatus=‘02‘ then 1 else null end) as deviceFailureNum,
round(COUNT(case when a.FStatus=‘02‘ then 1 else null end)/COUNT(a.FDEVICE_UUID), 4)*100||‘%‘ as deviceFailureRate,
round(COUNT(case when a.Fis_Active=‘1‘ then 1 else null end)/COUNT(a.Fis_Active), 4)*100||‘%‘ as deviceUsedNum,
round(count(case when b.Fis_Alarm=‘1‘ then 1 ELSE null end)/count(b.Fis_Alarm), 4)*100||‘%‘ as alrmPerDevice
from View_BD_DeviceInfo a
inner join View_MN_DeviceMonitorRec b on a.fsocial_uuid=b.fsocial_uuid
GROUP BY a.fsocial_uuid, a.fsocial_name
;

--11.View_BD_DeviceInfo和View_MN_DeviceMonitorRec View_BD_SocialPerson View_BS_PersonTrainTaskDtl 生成报表
select
a.fsocial_uuid,
a.fsocial_name,
count(c.FSocPerson_UUID) as Fscial_numOfPeople,
count(d.FPerson_UUID) as TrainedPeople,
round(count(case when d.Fis_Finish=‘1‘ then 1 else null end)/count(d.Fis_Finish), 4)*100||‘%‘ as passRate,
count(a.Fdevice_UUID) as deviceNum,
count(case when a.FStatus=‘02‘ then 1 else null end) as deviceFailureNum,
round(COUNT(case when a.FStatus=‘02‘ then 1 else null end)/COUNT(a.FDEVICE_UUID), 4)*100||‘%‘ as deviceFailureRate,
round(COUNT(case when a.Fis_Active=‘1‘ then 1 else null end)/COUNT(a.Fis_Active), 4)*100||‘%‘ as deviceUsedNum,
round(count(case when b.Fis_Alarm=‘1‘ then 1 ELSE null end)/count(b.Fis_Alarm), 4)*100||‘%‘ as alrmPerDevice,
count(e.FPatrolBusDtl_UUID) as numOfPatrol
from View_BD_DeviceInfo a
inner join View_MN_DeviceMonitorRec b on a.fsocial_uuid=b.fsocial_uuid
inner join View_BD_SocialPerson c on a.fsocial_uuid=c.fsocial_uuid
inner join View_BS_PersonTrainTaskDtl d on a.fsocial_uuid=d.fsocial_uuid
inner join View_bs_PatrolBusDtl e on a.fsocial_uuid=e.fsocial_uuid
GROUP BY a.fsocial_uuid, a.fsocial_name
;

--12.建表 建筑画像数据 ArchitecturePortraitData
create table ArchitecturePortraitData(
Fsocial_UUID varchar2(32) null,
Fsocial_Name varchar2(100) null,
Fscial_numOfPeople int null,
TrainedPeople int null,
passRate float(4) null,
deviceNum int null,
deviceFailureNum int null,
deviceFailureRate float(4) null,
deviceUsedNum float(4) null,
alrmPerDevice float(4) null,
numOfPatrol int null
)
;
comment on table ArchitecturePortraitData
is ‘建筑画像数据‘;
comment on column ArchitecturePortraitData.Fsocial_UUID
is ‘社会单位标识‘;
comment on column ArchitecturePortraitData.Fsocial_Name
is ‘社会单位名称‘;
comment on column ArchitecturePortraitData.Fscial_numOfPeople
is ‘各单位人数‘;
comment on column ArchitecturePortraitData.TrainedPeople
is ‘各单位参加培训人数‘;
comment on column ArchitecturePortraitData.passRate
is ‘各单位培训通过率‘;
comment on column ArchitecturePortraitData.deviceNum
is ‘各单位物联网设备总数‘;
comment on column ArchitecturePortraitData.deviceFailureNum
is ‘各单位物联网损坏数‘;
comment on column ArchitecturePortraitData.deviceFailureRate
is ‘各单位设备故障率‘;
comment on column ArchitecturePortraitData.deviceUsedNum
is ‘各单位设备启用率‘;
comment on column ArchitecturePortraitData.alrmPerDevice
is ‘各单位设备平均报警数‘;
comment on column ArchitecturePortraitData.numOfPatrol
is ‘各单位巡查数量‘;

alter table ArchitecturePortraitData add constraint pk_apd_fsocial_uuid primary key(Fsocial_UUID);

时间: 2024-08-06 19:42:08

建筑数据预处理脚本的相关文章

数据预处理速度高倍提升,3行python代码简单搞定!

Python 是机器学习领域内的首选编程语言,它易于使用,也有很多出色的库来帮助你更快处理数据.但当我们面临大量数据时,一些问题就会显现-- 目前,大数据(Big Data)这个术语通常用于表示包含数十万数据点的数据集.在这样的尺度上,工作进程中加入任何额外的计算都需要时刻注意保持效率.在设计机器学习系统时,数据预处理非常重要--在这里,我们必须对所有数据点使用某种操作. 在默认情况下,Python 程序是单个进程,使用单 CPU 核心执行.而大多数当代机器学习硬件都至少搭载了双核处理器.这意味

数据预处理(完整步骤)

原文:http://dataunion.org/5009.html 一:为什么要预处理数据?(1)现实世界的数据是肮脏的(不完整,含噪声,不一致)(2)没有高质量的数据,就没有高质量的挖掘结果(高质量的决策必须依赖于高质量的数据:数据仓库需要对高质量的数据进行一致地集成)(3)原始数据中存在的问题:不一致 —— 数据内含出现不一致情况重复不完整 —— 感兴趣的属性没有含噪声 —— 数据中存在着错误.或异常(偏离期望值)的数据高维度二:数据预处理的方法(1)数据清洗 —— 去噪声和无关数据(2)数

数据挖掘概念与技术读书笔记(三)数据预处理

3.1 数据预处理 数据质量的三个要素:准确性.完整性和一致性. 3.1.2 数据预处理的主要任务 数据清理:填写缺失的值,光滑噪声数据,识别或删除离群点,并解决不一致性来”清理“数据. 数据集成: 数据归约: 3.2 数据清理 3.2.1 缺失值 1.忽略元组 2.人工填写缺失值 3.使用一个全局常量填充缺失值 4.使用属性的中心度量填充缺失值:中位数 5.使用与给定元组属同一类的所有样本的属性均值或中位数 6.使用最可能的值填充缺失值:回归/贝叶斯/决策树 第6种是最流行的策略 3.2.2

《数据挖掘概念与技术》--第三章 数据预处理

一.数据预处理 1.数据如果能够满足其应用的要求,那么他是高质量的. 数据质量涉及许多因素:准确性.完整性.一致性.时效性.可信性.可解释性. 2.数据预处理的主要任务:数据清洗.数据集成.数据规约.数据变换. 二.数据清理:试图填充缺失值,光滑噪声.识别利群点.纠正数据中的不一致. 1.缺失值的处理: 1)忽略元组:缺少类标号时通常这么做.但是忽略的元组其他属性也不能用,即便是有用的. 2)人工填写:该方法很费事费时,数据集很大.缺失值很多时可能行不通. 3)使用一个全局常量填充缺失值:将缺失

WEKA中的数据预处理

数据预处理包括数据的缺失值处理.标准化.规范化和离散化处理. 数据的缺失值处理:weka.filters.unsupervised.attribute.ReplaceMissingValues. 对于数值属性,用平均值代替缺失值,对于nominal属性,用它的mode(出现最多的值)来代替缺失值. 标准化(standardize):类weka.filters.unsupervised.attribute.Standardize.标准化给定数据集中所有数值属性的值到一个0均值和单位方差的正态分布.

sklearn数据预处理-scale

对数据按列属性进行scale处理后,每列的数据均值变成0,标准差变为1.可通过下面的例子加深理解: from sklearn import preprocessing import numpy as np 测试数据: X = np.array([[1., -1., 2.], [2., 0., 0.], [0., 1., -1.]]) 使用sklearn进行scale处理时,有两种方式可供选择. 方式1:直接使用preprocessing.scale()方法: X_scaled = preproc

数据预处理技术

数据预处理技术数据清理:空缺值处理.格式标准化.异常数据清除.错误纠正.重复数据的清除数据集成:将多个数据源中的数据结合起来并统一存储,建立数据仓库的过程实际上就是数据集成.数据变换:平滑.聚集.规范化.最小 最大规范化等数据归约:维归(删除不相关的属性(维)).数据压缩(PCA,LDA,SVD.小波变换).数值归约(回归和对数线形模型.线形回归.对数线形模型.直方图)数据离散化和概念分层 1.数据清理:格式标准化.异常数据清除.错误纠正.重复数据的清除通过填写空缺值,平滑噪声数据,识别删除孤立

使用sqoop从mysql往hive中增量导数据shell脚本

一:sqoop增量导入的两种方式 Incremental import arguments: Argument Description --check-column (col) Specifies the column to be examined when determining which rows to import. (the column should not be of type CHAR/NCHAR/VARCHAR/VARNCHAR/ LONGVARCHAR/LONGNVARCHA

sqlserver导出带数据的脚本

说明: 以前要将一个表中的数据导出为脚本,只有用存储过程.现在在SQL Server 2008中增加了一个新特性,除了导出表的定义外,还支持将表中的数据导出为脚本. 步骤: 右击需要导出数据的数据库,在弹出式菜单中选择"任务"下的"生成脚本"选项 在第二步选择"高级选项"如果不是2008(R2)的选择 "编写数据的脚本"选择为TRUE,这里默认是为FALSE的 ,   是2008(R2)的选择"要编写的脚本的数据的类