易截截图软件、单文件、免安装、纯绿色、仅160KB

Oracle的 简单行转列

应个报表要求做个
时间             双色球,  胜负彩。。。。。
200905     销量       销量
200906     销量       销量
200907     销量       销量
200908     销量       销量
一个SQL 语句得到结果是:
f_yearmonth, lot_name,money
200905   双色球    50
200905   胜负彩   100
200906   双色球   60
200906   胜负彩    70
Select f_yearmonth,
Max(decode(f_lotname,'双色球',f_money,0)) As "双色球",
Max(decode(f_lotname,'福彩3D',f_money,0)) as "福彩3D",
Max(decode(f_lotname,'胜负彩',f_money,0)) as "胜负彩",
Max(decode(f_lotname,'时时彩',f_money,0)) as "时时彩",
Max(decode(f_lotname,'时时乐',f_money,0)) as "时时乐",
 from
 t_tmp_test_A
 Group By f_yearmonth
 Order By f_yearmonth
关键语句:
 Max(decode(f_lotname,'双色球',f_money,0)) As "双色球",
 Group By f_yearmonth
应为 按时间重组只有一条,并且只有一条数据:  200905   双色球    50 
那么 用MAX取一条数据 就是50
decode 意思说 如果是‘双色球’ 取对应的f_money  并且放在 命名为 "双色球"的 列上。
很显然 这列是固定!


相关文档:

ORACLE PL/SQL包(package)学习笔记

包由包规范和包体两部分组成。
 
1、包规范(Package Specification)
包规范,也叫做包头,包含了有关包的内容的信息。但是,它不包含任何过程的代码。
创建包头的语法一般如下
 
CREATE [OR REPLACE] PACKAGE package_name {IS | AS}
Procedure_name | function_name | variable_declaration | type_def ......

ORACLE PL/SQL 对象(object)学习笔记(一)

 1、对象类型规范
 
创建对象类型规范的语法如下
 
CREATE [OR REPLACE] TYPE [schema.] type_name
[AUTHID {CURRENT_USER|DEFINER}] AS OBJECT (
Attribute1 datatype,
[attribute2 datatype,…]
[method 1]
[method 2]);
/

 
 
 
其中AUTHID指示将来执行该方法时, ......

ROLLUP和CUBE语句。 ORACLE分组统计


ROLLUP和CUBE语句。
Oracle的GROUP
BY语句除了最基本的语法外,还支持ROLLUP和CUBE语句。如果是ROLLUP(A, B, C)的话,首先会对(A、B、C)进行GROUP
BY,然后对(A、B)进行GROUP BY,然后是(A)进行GROUP BY,最后对全表进行GROUP BY操作。如果是GROUP BY
CUBE(A, B, C),则首先会对(A、B、C)进行GROUP
BY,然后依次是( ......

将数据导入到Oracle中

1. create table people (age int, id int);
2. 创建数据文件PeopleDate.txt.
    数据为:   
              20,1
              30,2
3. 创建 ......

Connecting Oracle with MS


This article shows how Oracle's Heterogeneous Services can be configured to allow a database to connect to a Microsoft Access database using standard databases links. The method described can be used to connect to MS-Access from about any platform - Unix/ Linux or Windows.
MS-Access 2003 and Orac ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号