Sybase iq随笔学习(20151027)

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

/*用户订购RFM的计算*/
 (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

时间: 2024-09-30 11:51:56

Sybase iq随笔学习(20151027)的相关文章

SAP Sybase IQ EVENT Each time a scheduled event handler is completed

16.0 SP04 > Reference: Statements and Options > SQL Statements Defines an event and its associated handler for automating predefined actions. Also defines scheduled actions. Quick Links: Go to Parameters Go to Examples Go to Usage Go to Standards Go

Sybase IQ如何将大文件数据迅速加载到数据库

试想一下,如果一个文件5G.10G甚至更大.如何将它迅速地加载到数据库指定的表呢?我们看看Sybase IQ是如何迅速地将表的数据加载到数据库的. 数据文件格式: 1440,2011-01-09 00:00:00,1,珠海,1,C网,8612345678222,221943,1,12175,1,12,14426467,1191632,9,1440,2011-01-09 00:00:00,1,珠海,1,C网,8612345678222,968852,1,82077,1,7,2430696,1349

sybase iq数据库load表字符集乱码

公司领导要我导一个文件到sybase iq数据库一张表中,load表语句如下: load table kyfx_ci_loc(  city_name ',',   county_id  ci_name ',',  ci_section ',',  ci_id ',',  ci_longtitude_gps ',',  ci_latitude_gps ',',  ci_longtitude_baidu ',',  ci_latitude_baidu 0x0a)  using file '/home

Sybase IQ使用过程中注意事项

Sybase IQ使用过程中注意事项 1,字母大小写比对不敏感,也就是在值比对判断时大小写字母都一样; 2,等值,或<>判断,系统默认对等式两边比对值去右边空格再进行比较: 3,GROUP BY 可以根据SELECT字段或表达式的别名来 汇总,在编写时也尽量避免SELECT 语句的别名与FROM表中的字段有重复,不然会出现莫名其妙的错误: 4,FROM后的子查询 要定义别名才可使用: 5,存储过程要返回IQ系统错误信息 SQLCODE || ERRORMSG(*) :(两者都为EXCEPTIO

SAP Sybase IQ 操作基础

1.启动 source IQ-16_0.sh 命令行查看安装程序是否成功 start_iq -v2 2.数据库.表空间 start_iq -n utility_db dbisql -c 'uid=dba;pwd=sql;eng=utility_db;dbn=utility_db' -nogui -- 建立数据库 (DBA)> CREATE DATABASE '/sybaseiq160/T2/anos.db' IQ PATH '/sybaseiq160/T2/iq_system_main.iq'

Sybase IQ导出文件的几种方式

IQ有四种方法,将表的数据导出为文本文件:1.重定向 SELECT * FROM TABLE1 ># D:MYDATATABLE1.TXT -- 文件生成在执行语句的客户端上 2.通过选项导出 SET TEMPORARY OPTION Temp_Extract_Name1 = '/data/mydata/table1.txt'; SET TEMPORARY OPTION Temp_Extract_Name2 = ’’; SELECT * FROM TABLE1; (将查询结果写入 table1.

07.23 课堂随笔 学习了相关的标签

<!doctype html><html><head><meta charset="utf-8"><title>无标题文档</title></head> <body> <pre> html标签 <标签名 属性名1=属性值1 属性名2=属性值2> 内容 </标签名> 标签的正确嵌套方式: <标签名 属性名1="属性值1" 属性名2=

Sybase数据库技术,数据库恢复---分享Sybase数据库知识(博客文章索引@51cto)

Sybase数据库技术,数据库恢复分享Sybase数据库知识 博客文章列表,更新时间:2014-12-14 Sybase数据库技术,数据库恢复 站点地图 最新文章 ASE使用with ignore_dup_row删除重复数据  (评论 0   阅读 50) ASE 16静默方式安装并创建服务器  (评论 0   阅读 80) ASE执行sp_remotesql报错:Msg 11224, Level 16, State 2  (评论 0   阅读 72) Sybase支持浪潮天梭K1系统  (评论

Universe Design Tool Using JDBC connect Sybase Get Error

1 使用SAP Universe 设计工具连接Sybase数据库报错,报错如下: “CS: Java Class not found in classpath : com.sybase.jdbc4.jdbc.SybDriver” 或者报错如下: “CS: Java Class not found in classpath : com.sybase.jdbc3.jdbc.SybDriver” 2 我的环境如下: 操作系统:win7,安装的是:SAP BusinessObjects BI 平台 4