数据统计

--1.把自己的抓的数据存入和自己表结构一样的
sanya_result_test_all(总数据)
sanya_result_test_new(新增数据)
sanya_result_test_old(重复数据)

--运行importance类的java程序,根据mer_name(店铺名称)与NM_SHOP(shop_name)进行相似度比较
--判断出 重复数据和新增数据;分别导入sanya_result_test_new和sanya_result_test_old表中

--1.
--首先根据店铺名称和  NM_SITE_ENT(is_zt字段标记1 意为新增) 表中的ENT_NAME进行对比,
--如果该店铺在 NM_SITE_ENT 表中存在,则不需要向NM_SITE_ENT中插入数据,取出对应的site_ent_id,向nm_shop表中插入一条数据,
--shop_id(自动生成),site_ent_id,platform_code(平台),SHOP_NAME(店铺名称),SHOP_ADDRESS(店铺地址),Shop_URL(店铺URL),SHOP_CONTENT(店铺内容),HPL(总体评分),EV_NUM(评价总数),ADD_TIME(录入时间当前时间),LASTDATE(当前时间),BAD_EV_NUM(差评总数),IS_EV(是否评价,默认为0)

--2.如果店铺不在NM_SITE_ENT 中存在
--先生成一个site_ent_id,
--向NM_SITE_ENT  中插入一条数据
--ENT_NAME(主体名称,店铺名称),IS_ILLEGAL(是否合法,默认是0),ADD_TIME(添加日期默认当前),AREA(网站所属区域 100三亚,101陵水,102保亭,103乐东),MANAGER_ILLEGAL(判定结果默认 0),EST_DATE(成立日期),ZT_ADDRESS(地址),REGISTERED_CAPITA(注册资本),LEGAL_REPRESENTATIVE(法定代表人),ENTERPRISE_TYPE(企业类型),BUSINESS_SCOPE(经营范围),IS_ZT(状态 新增 为2)
--在向nm_shop中添加一条数据  site_ent_id 是刚才插入NM_SITE_ENT中的site_ent_id ,shop_id自动生成

--查询平台
select * from PUB_CODETABLE where codetable='sjly'

--添加中国通用网 和 悠哉旅游网 两个平台。

--3.如果下次插入数据 首先将NM_SITE_ENT  中的IS_ZT为2的更新为0(is_zt字段标记2 意为新增)
--NM_SITE_ENT表中的IS_ZT字段意义:2 是新增, 1是旧的, 0是不存在

--修改当前时间语句
update nm_site_ent t set t.add_time =sysdate  where t.is_zt =2;



--2016-7-27

--(nm_shop表中插入的新数据)
SELECT * FROM nm_shop t WHERE 1=1 AND to_char(add_time,'YYYY-MM-DD HH12:MI:SS') like '%2016-07-27 11:43:00%'; 
--导入语句

--同一个数据库,同样的表结构导入数据
INSERT INTO nm_site_ent2 (SELECT * FROM nm_site_ent);

--创建相同的表
create table  table_name1 as select * from table_name2

--1.可以通过导出.dmp文件导入数据

--2.也可以通过excel导出和导入注意code,单元格设置为文本类型,关联表NM_SHOP_TYPE()
1 酒店   100     1001
2 美食 106     10602
3 度假 104     10406
4 婚纱摄影 107     107
5 租车 105     10501
6 跟团游 104      10401
7 景点门票 109      109

--查询分类
select * from pub_codetable where codetable='big'


-----------------------
--注意:1默认在c:/用户/administer)
--exp sywj/sywj@ORCL file=nm_shop_good.dmp tables=(nm_shop_good)

--导入四张表
nm_shop 店铺表

nm_site_ent 主体表

nm_shop_type 店铺分类表

nm_evaluation 评论表

--关联查询子表count
--阶段统计 sql
select a.shop_id as 店铺编号,a.shop_name as 店铺名称,
a.platform_code as 平台编号,a.shop_address as 店铺地址 ,a.shop_url as url,
a.ev_num as 总评数量,a.bad_ev_num as 总差评数,
(select count(1) from z_nm_evaluation_totle6789 b where b.shop_id=a.shop_id and (substr(b.ev_time, 6, 1)='8' or substr(b.ev_time, 6, 1)='6') ) as 啊6到7月总评论数,
(select count(1) from z_nm_evaluation_totle6789 b where b.shop_id=a.shop_id and b.is_bad='1' and (substr(b.ev_time, 6, 1)='8' or substr(b.ev_time, 6, 1)='7')) as 啊6到7月差评论数,
(select count(1) from z_nm_evaluation_totle6789 b where b.shop_id=a.shop_id and (substr(b.ev_time, 6, 1)='8' or substr(b.ev_time, 6, 1)='9') ) as 啊8到9月总评论数,
(select count(1) from z_nm_evaluation_totle6789 b where b.shop_id=a.shop_id and b.is_bad='1' and (substr(b.ev_time, 6, 1)='8' or substr(b.ev_time, 6, 1)='9')) as 啊8到9月差评论数
from a_nm_shop_8_9 a


--截取日期
update a_nm_evaluation_8_9_kai_tm_2 set ev_time=replace(ev_time,substr(ev_time,8,1),'') where ev_time like '_______0%'



猜你喜欢

转载自st4024589553.iteye.com/blog/2334691