常用select语句
- 格式:doc
- 大小:304.50 KB
- 文档页数:33
1、从pb导出数据:
select * from ts_mxh_user_info where stat_month=200712 and city_code='E19A'; 另存
类型 Dbase3
select * from ts_mxh_user_info where stat_month=200901 and city_code='E19A' and
serial_number like ‘13%’;
select * from ts_mxh_user_info where stat_month=200901 and city_code='E19A' and
serial_number not like ‘13%’;
select * from ts_mxh_user_info where stat_month=200901 and city_code='E19B'
select * from ts_mxh_user_info where stat_month=200901 and city_code='E19C'
select * from ts_mxh_user_info where stat_month=200901 and city_code='E19D'
select * from ts_mxh_user_bill where stat_month=200901
2、追加记录:
use e:\mbg\info0712
appen from e:\mbg\info0712_1
appen from e:\mbg\info0712_2
3、核对info表:
PB:select count(*),sum(bill_fee/100) from ts_mxh_user_info where stat_month=200712 ;
VF:sele sum(bill_fee/100) from e:\mbg\info0812
VF:sele sum(fee_sum) from e:\mbg\bill0812
VF:sele sum(debt_fee/100) from e:\mbg\info0812
VF:sele sum(fee_sum) from e:\mbg\debt0812
4、提取公话数据:
引用e:\mbg\移动公话用户每月欠费清单
提取乡镇团场公话通话统计
Do e:\mbg\计算每月通话用户数_07年乡镇团场公话通话统计.PRG
modify command e:\mbg\统计移动公话每月欠费清单.PRG
do e:\mbg\统计移动公话每月欠费清单.PRG
modify command e:\mbg\2008年公话相关数据统计_原件.prg
5、各营业部净增通话:发电子邮件
计算每月通话用户数_07年乡镇团场营业厅净增通话统计0802.PRG
计算每月净增通话统计表的指标语句.PRG
计算营业厅当月欠费回收率_2007年5月重新改0802.prg
统计移动公话和红名单等当月欠费回收率.prg
6、关联集团信息化收入、短信费
sele * from e:\mbg\集团信息化收入统计表_总个数577.dbf group by 手机号码
sele a.*,b.city_code,b.bill_fee/100 as 收入12月,bill_fee_m/100 as 短信费12月 from e:\mbg\集团信息化收入统计表_总个数577.dbf a,e:\mbg\info0712 b where a.手机号码=b.serial_num
and b.bill_fee/100>0
copy to e:\mbg\t1
sele * from e:\mbg\集团信息化收入统计表_总个数577 where 手机号码 not in (sele 手机号码 from e:\mbg\t1)
copy to e:\mbg\t2
close all
use e:\mbg\t1
appen from e:\mbg\t2
copy to e:\mbg\集团信息化收入统计表_总个数580_12月收入 type xls
7、sele 手机号,count(*) from e:\mbg\2007年9月末梢代办放号清单 group by 手机号
8、提取零次用户清单 发电子邮件给市场部主任业务区经理副经理管理员
Do e:\mbg\提取每月零次用户的情况.PRG
9、提取乡镇团场公话通话统计
Do e:\mbg\计算每月通话用户数_07年乡镇团场公话通话统计.PRG
10、计算代销代办每月 入网第4个月的在网率
核实号码是否重复:sele 手机号,count(*) from e:\mbg\4月末稍代办放号清单 group by 手机号
copy to e:\mbg\t3
sele * from e:\mbg\t3 where cnt>1
sele er_id,a.* from e:\mbg\2007年9月末梢代办放号清单 a,e:\mbg\info0709 b where a.手机号=b.serial_num and b.arrive_tag='1'
copy to e:\mbg\t0
sele a.*,er_state,b.debt_fee/100 as 往月欠费,stat_month as 统计月份 from e:\mbg\t0
a,e:\mbg\info0712 b where er_id=er_id order by 业务区,部门,代销商
copy to e:\mbg\t1
select a.*,erstate as 状态 from e:\mbg\t1 a,e:\mbg\userstate b where
er_state=rstateco
copy to e:\mbg\2007年9月末梢代办放号清单_在第4个月清单
copy to e:\mbg\2007年9月末梢代办放号清单_在第4个月清单 type xls
sele 业务区,部门,代销商,count(*) as 在网数 from e:\mbg\2007年9月末梢代办放号清单_在第4个月清单 where 状态 in ('开通','高额停机') and 往月欠费=0 group by 业务区,部门,代销商 order
by 业务区,部门
copy to e:\mbg\2007年9月末梢代办放号清单_在第4个月在网汇总 type xls
sele er_id,a.* from e:\mbg\2007年9月营销员放号清单.dbf a,e:\mbg\info0709 b where a.手机号=b.serial_num and b.arrive_tag='1' copy to e:\mbg\t0
sele a.*,er_state,b.debt_fee as 往月欠费,stat_month as 统计月份 from e:\mbg\t0
a,e:\mbg\info0712 b where er_id=er_id order by 业务区,营销员姓名
copy to e:\mbg\t1
select a.*,erstate as 状态 from e:\mbg\t1 a,e:\mbg\userstate b where
er_state=rstateco
copy to e:\mbg\2007年9月营销员放号清单_在第4个月清单
copy to e:\mbg\2007年9月营销员放号清单_在第4个月清单 type xls
sele 业务区,营销员姓名,count(*) as 在网数 from e:\mbg\2007年9月营销员放号清单_在第4个月清单 where 状态 in ('开通','高额停机') and 往月欠费=0 group by 业务区,营销员姓名 order by 业务区,营销员姓名
copy to e:\mbg\2007年9月营销员放号清单_在第4个月在网汇总 type xls
10、sele from where a.in_date>={^2007-7-1} and a.substr(SERVICE_US,2,1)<>'1 and
a.public_tag='0' and b.
11、sele 负责人所在,负责人,count(*),sum(欠费金额),sum(扣罚金额) from e:\mbg\扣罚明细清单080112 group by 负责人所在,负责人
12、李斌(李斌) 11:19:25
就是在7月以后入网的用户从来没有开通过彩铃业务,剔除公话及买希腊普卡用户,要用户的手机号码及消费及是否开通
sele serial_num,user_id,bill_fee/100 as 消费,user_state as 状态 from e:\mbg\info0712 where
arrive_tag='1' and in_date>={^2007-7-1} and substr(SERVICE_US,2,1)<>'1' and public_tag
not in ('1','2','3') and user_id in (sele user_id from e:\mbg\discnt0712 where
discnt_cod<>20000416 and discnt_cod<>20001933)
copy to e:\mbg\t1
sele a.*,erstate from e:\mbg\t1 a,e:\mbg\userstate b where a.状态=rstateco
copy to e:\mbg\未开通彩铃清单_李斌数据 type xls
copy to e:\mbg\未开通彩铃清单_李斌数据 deli with tab
13 、前两个月月消费均在100-300元;2、客户品牌神州行天山通;2、需求1600户。
sele stat_month,user_id,serial_num as 手机号码,cust_name as 客户姓名,city_code as 业务区,in_date as 开户时间,folk_code as 民族,age as 年龄,bill_fee/100 as 本月消费 from
e:\mbg\info0712 where brand_code='G002' and user_state='0' and arrive_tag='1' and
bill_fee/100>=100 and bill_fee/100<=300
copy to e:\mbg\t1
sele a.*, b.bill_fee/100 as 上月消费 from e:\mbg\t1 a,e:\mbg\info0711 b where
er_id=er_id and b.bill_fee/100>=100 and b.bill_fee/100<=300