博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用户订购RFM的计算
阅读量:5771 次
发布时间:2019-06-18

本文共 3327 字,大约阅读时间需要 11 分钟。

hot3.png

BULK insert A from 'C:/CDR201301.txt' --批量插入表

sp_iqcolumn('tv_user')                --查看表中数据列

/*CASE..WHEN条件选择*/

select distinct case when tv_vod.series_flag = 1 then tv_vod.series_id   else tv_vod.program_id  end item_id,
       case when tv_vod.series_flag = 1 then tv_vod.series_name else tv_vod.program_name end item_name,
tv_castrolemap.castrole_type, tv_cast.cast_id, tv_cast.cast_name into item_cast
from tv_contentmapping, tv_vod, tv_castrolemap, tv_cast
where tv_contentmapping.parent_id = tv_vod.program_id
and tv_contentmapping.element_id = tv_castrolemap.castrole_id
and tv_castrolemap.cast_id = tv_cast.cast_id
and tv_contentmapping.element_type = 7

 (select L.R,max(L.R) as gt,min(L.R)as lt from
(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408_tmp group by s_userid)L group by L.R)
select min(L.R),max(L.R)-min(L.R),min(L.F),max(L.F)-min(L.F),min(L.M),max(L.M)-min(L.M) from
(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408 group by s_userid)L
select L.s_userid,convert(numeric(8,6),-avg(L.R)/30) as Rl,convert(numeric(8,6),(1-avg(L.F))/240) as F1,
convert(numeric(8,6),(-avg(L.M))/2671) as M1 from
(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408 group by s_userid)L group by L.s_userid

select name from sysobjects where  type='U'

select max(L.F), from

(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408_tmp group by s_userid)L

select L.s_userid,convert(numeric(8,6),(1-avg(L.F))/41) as F1 from

(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408_tmp group by s_userid)L group by L.s_userid

select max(L.M),min(L.M),max(L.M)-min(L.M) from
(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408_tmp group by s_userid)L

select L.s_userid,convert(numeric(8,6),(3-avg(L.M))/395) as M1 from

(select s_userid,datediff(dd,max(substring(s_maxdate,1,8)),'20140831') as R,sum(s_count)
as F,sum(s_fee) as M from iac_fct_m201408_tmp group by s_userid)L group by L.s_userid

select s.mdn, s.cdr_city_id, s.area_id, s.mdn_prov_id, t.s_cycle_date is_find
from areaky00001 s left join
(select min(k.s_cycle_date) s_cycle_date, k.mdn, k.cdr_city_id
from areaky00001 k
where k.cdr_city_id != k.mdn_city_id
group by k.mdn, k.cdr_city_id) t
on s.s_cycle_date = t.s_cycle_date and s.mdn = t.mdn and s.cdr_city_id = t.cdr_city_idk.cdr_city_id

/*人数按省份排名比例*/
select M.cdr_city_id,M.city_name,M.f_rank,M.mdn_prov_id,M.cp_name,convert(char(25),f_count*100/f_total)||'%' as f_rate
from (select cdr_city_id,city_name,mdn_prov_id,cp_name,count(distinct mdn) as f_count,rank() over(partition by cdr_city_id order by f_count desc) as f_rank  from tmp_lvj_quansheng,kyfx_cfg_city,kyfx_cfg_province
 where convert(int,city_id)=cdr_city_id and mdn_prov_id=cp_id
group by  cdr_city_id,city_name,cp_name,mdn_prov_id)M,(select cdr_city_id,count(distinct mdn) as f_total from tmp_lvj_quansheng
group by cdr_city_id)N where  M.cdr_city_id=N.cdr_city_id

 

转载于:https://my.oschina.net/u/1866459/blog/522782

你可能感兴趣的文章
Scrapy基本用法
查看>>
PAT A1030 动态规划
查看>>
自制一个 elasticsearch-spring-boot-starter
查看>>
软件开发学习的5大技巧,你知道吗?
查看>>
java入门第二季--封装--什么是java中的封装
查看>>
【人物志】美团前端通道主席洪磊:一位产品出身、爱焊电路板的工程师
查看>>
一份关于数据科学家应该具备的技能清单
查看>>
机器学习实战_一个完整的程序(一)
查看>>
Web框架的常用架构模式(JavaScript语言)
查看>>
如何用UPA优化性能?先读懂这份报告!
查看>>
这些Java面试题必须会-----鲁迅
查看>>
Linux 常用命令
查看>>
NodeJS 工程师必备的 8 个工具
查看>>
CSS盒模型
查看>>
ng2路由延时加载模块
查看>>
使用GitHub的十个最佳实践
查看>>
全面了解大数据“三驾马车”的开源实现
查看>>
脱离“体验”和“安全”谈盈利的游戏运营 都是耍流氓
查看>>
慎用!BLEU评价NLP文本输出质量存在严重问题
查看>>
Facebook Sonar:一款可视化及交互式移动应用调试工具
查看>>