技术标签: oracle 查询数据横向
因为要牵扯到小计,所以需要计算两次。
想法:
1、把查询到的结果,插入到临时表,
2、把统计结果插入到临时表。
3、查询临时表记录放置到游标中。
4、删除临时表记录。
包的定义声明:
复制代码 代码如下:
CREATE OR REPLACE PACKAGE CHEN_TEST_PACKGE IS
type cursor_type is ref cursor;
/************************************************************************************/
/* 功能说明:查询某种公告报表 */
/* 参数说明: */
/* i_id_capital_dynamic_manage IN VARCHAR2 某种公告ID */
/* o_cursor OUT cursor_type 返回游标 */
/* */
/* 创建日期 姓名 */
/* 2013-03-08 路人甲 */
/************************************************************************************/
PROCEDURE p_list_bulletin_report( i_id_capital_dynamic_manage IN VARCHAR2,
o_cursor OUT cursor_type);
END CHEN_TEST_PACKGE;
包的实现:
复制代码 代码如下:
CREATE OR REPLACE PACKAGE BODY CHEN_TEST_PACKGE IS
/************************************************************************************/
/* 功能说明:查询某种公告报表 */
/* 参数说明: */
/* i_id_capital_dynamic_manage IN VARCHAR2 某种公告ID */
/* o_cursor OUT bulletin_report_type 返回游标 */
/* */
/* 创建日期 姓名 */
/* 2013-03-08 路人甲 */
/************************************************************************************/
PROCEDURE p_list_bulletin_report( i_id_capital_dynamic_manage IN VARCHAR2,
o_cursor OUT bulletin_report_type)
AS
set_id_bulletin_report_temp VARCHAR2(50); -- 定义临时变量
BEGIN
begin
--给临时变量赋值
--select to_char(sysdate,'yyyymmddhh24missSSS') into set_id_bulletin_report_temp from dual;
select i_id_capital_dynamic_manage into set_id_bulletin_report_temp from dual;
--获取数据插入临时表
insert into scms_bulletin_report_temp
(
id_bulletin_report_temp,
biz_Name ,
t01 ,
t07 ,
t14 ,
t21 ,
t1M ,
t2M ,
t3M ,
t4M ,
t5M ,
t6M ,
t1Y ,
t2Y ,
tCount ,
sort_no
)
select c.*,
rownum as sort_no
from(
select
set_id_bulletin_report_temp as id_bulletin_report_temp,
scms_common_packge.get_biz_name(b.biz_id) as biz_Name,
max(case when b.term_type='T01' then b.c else 0 end) as T01,
max(case when b.term_type='T07' then b.c else 0 end) as T07,
max(case when b.term_type='T14' then b.c else 0 end) as T14,
max(case when b.term_type='T21' then b.c else 0 end) as T21,
max(case when b.term_type='T1M' then b.c else 0 end) as T1M,
max(case when b.term_type='T2M' then b.c else 0 end) as T2M,
max(case when b.term_type='T3M' then b.c else 0 end) as T3M,
max(case when b.term_type='T4M' then b.c else 0 end) as T4M,
max(case when b.term_type='T5M' then b.c else 0 end) as T5M,
max(case when b.term_type='T6M' then b.c else 0 end) as T6M,
max(case when b.term_type='T1Y' then b.c else 0 end) as T1Y,
max(case when b.term_type='T2Y' then b.c else 0 end) as T2Y,
sum(b.c) as BIZ_ID_COUNT
from
(
select a.term_type,a.biz_id, sum(a.capital_claim) c
from (select report.capital_claim,
report.biz_id,
detail.term_type
from scms_capital_claim_report report,
scms_capital_assign_detail detail,
scms_capital_dynamic_manage manager
where manager.id_capital_dynamic_manage = detail.id_capital_dynamic_manage
and report.id_capital_assign_detail = detail.id_capital_assign_detail
and detail.id_capital_dynamic_manage = i_id_capital_dynamic_manage
and manager.IS_SETTLEMENT = '1'
and manager.IS_CONFIRM = '1'
) a
group by a.term_type, a.biz_id
) b group by b.biz_id
) c;
-- 插入总记录数
insert into scms_bulletin_report_temp
(
id_bulletin_report_temp,
biz_Name ,
t01 ,
t07 ,
t14 ,
t21 ,
t1M ,
t2M ,
t3M ,
t4M ,
t5M ,
t6M ,
t1Y ,
t2Y ,
tCount ,
sort_no
)
select c.*,
(select max(sort_no)+1 from scms_bulletin_report_temp te where te.id_bulletin_report_temp = set_id_bulletin_report_temp ) as sort_no
from(
select
set_id_bulletin_report_temp as id_bulletin_report_temp,
'总计(天数)' as biz_Name,
max(case when b.term_type='T01' then b.c else 0 end) as T01,
max(case when b.term_type='T07' then b.c else 0 end) as T07,
max(case when b.term_type='T14' then b.c else 0 end) as T14,
max(case when b.term_type='T21' then b.c else 0 end) as T21,
max(case when b.term_type='T1M' then b.c else 0 end) as T1M,
max(case when b.term_type='T2M' then b.c else 0 end) as T2M,
max(case when b.term_type='T3M' then b.c else 0 end) as T3M,
max(case when b.term_type='T4M' then b.c else 0 end) as T4M,
max(case when b.term_type='T5M' then b.c else 0 end) as T5M,
max(case when b.term_type='T6M' then b.c else 0 end) as T6M,
max(case when b.term_type='T1Y' then b.c else 0 end) as T1Y,
max(case when b.term_type='T2Y' then b.c else 0 end) as T2Y,
sum(b.c) as BIZ_ID_COUNT
from
(
select a.term_type,'biz_id_count' as biz_id, sum(a.capital_claim) c
from (select report.capital_claim,
report.biz_id,
detail.term_type
from scms_capital_claim_report report,
scms_capital_assign_detail detail,
scms_capital_dynamic_manage manager
where manager.id_capital_dynamic_manage = detail.id_capital_dynamic_manage
and report.id_capital_assign_detail = detail.id_capital_assign_detail
and detail.id_capital_dynamic_manage = i_id_capital_dynamic_manage
and manager.IS_SETTLEMENT = '1'
and manager.IS_CONFIRM = '1'
) a
group by a.term_type
) b group by b.biz_id
) c;
-- 查询刚刚插入的表记录
open o_cursor for
select
id_bulletin_report_temp as idBulletinReportTemp,
biz_Name as bizName ,
t01 as t01 ,
t07 as t07 ,
t14 as t14 ,
t21 as t21 ,
t1M as t1M ,
t2M as t2M ,
t3M as t3M ,
t4M as t4M ,
t5M as t5M ,
t6M as t6M ,
t1Y as t1Y ,
t2Y as t2Y ,
tCount as tCount,
sort_no as sortNo
from scms_bulletin_report_temp temp
where temp.id_bulletin_report_temp = set_id_bulletin_report_temp
order by sortNo asc;
-- 删除:根据ID删除刚刚插入的记录
delete from scms_bulletin_report_temp temp where temp.id_bulletin_report_temp = set_id_bulletin_report_temp;
commit;
end;
END p_list_bulletin_report;
END CHEN_TEST_PACKGE;
/
页面调用ibatis的xml配置查询结果:
复制代码 代码如下:
{call CHEN_TEST_PACKGE.p_list_bulletin_report(?,?)}
java调用:
复制代码 代码如下:
String id_capital_dynamic_manage = request.getParameter("id_capital_dynamic_manage");
Map paraMap = new HashMap();
paraMap.put("i_id_capital_dynamic_manage", id_capital_dynamic_manage);
// 调用存储过程,查询
List resultList = (List>) CURDUtil.queryList("queryBulletinReportList", paraMap);
页面显示jsp:
复制代码 代码如下:
http://www.dengb.com/oracle/340039.htmlwww.dengb.comtruehttp://www.dengb.com/oracle/340039.htmlTechArticle因为要牵扯到小计,所以需要计算两次。 想法: 1、把查询到的结果,插入到临时表, 2、把统计结果插入到临时表。 3、查询临时表记录放...
#include <iostream>#include <string.h>#include<vector>#include<algorithm>using namespace std;int main(){ int n; cin>>n; vector<int> v; vector<int> res; for(int i=.
Go 语言的字典类型其实是一个哈希表(hash table)的特定实现,它能存储的不是单一值的集合,而是键-元素对的集合。在这个实现中,键和元素的最大不同在于,前者的类型是受限的,而后者却可以是任意类型的。带着问题map的底层结构是什么样的?map的键值映射过程?键不能是哪些类型?为什么?map是什么情况下扩容?for range map为什么是无序的?map基础数据结构ma...
薪资高、市场广、机会多、缺口大,让大数据成了开发圈子里的香饽饽。麦肯锡公司报告指出,大数据、人工智能方面人才紧缺,需求量激增,企业用于大数据业务的支出将突破5000亿元。根据各招聘网站权...
控制台输出乱码如下:[DEBUG] o.a.ibatis.io.DefaultVFS.findJarForResource - Find JAR URL: file:/E:/java/git-project/rbac/target/rbac-1.0-SNAPSHOT/WEB-INF/classes/com/ale/entity/Permission.class[DEBUG] o.a.ibat...
8种机械键盘轴体对比本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?被垃圾主板坑了,笔记本的hdmi口是从独显接出来的,但是我的kali上又没有安装NVIDIA的官方驱动,所以显示器接上去没有反应。为了解决这个问题,先要安装NVIDIA的官方驱动,再修改xconfig以及xrandr的设置。安装NVIDIA驱动1.禁用nouveau123echo -e "blacklist nouvea...
最近在做双目测距,觉得有必要记录点东西 双目测距属于立体视觉这一块,我觉得应该有很多人踩过这个坑了,但网上的资料依旧是云里雾里的,要么是理论讲一大堆,最后发现还不知道怎么做,要么就是直接代码一贴,让你懵逼。 所以今天我想做的,是尽量给大家一个明确的阐述,并且能够上手做出来。一、 标定 首先我们要对摄像头做标定,具体的公式推导在learning opencv中有详细的解释,这里顺带
首先,我自己定义了枚举变量 Sign:enum Sign{ plus,minus};编译时 出现如下错误:解决办法:避免自己在结构体定义中使用 "plus"以及“minus”比如改为:enum Sign{ positive,negative};
转载:http://www.cnblogs.com/gakusei/articles/1585211.html为了支持Unicode编码,需要多字节与宽字节之间的相互转换。这两个系统函数在使用时需要指定代码页,在实际应用过程中遇到乱码问题,然后重新阅读《Windows核心编程》,总结出正确的用法。WideCharToMultiByte的代码页用来标记与新转换的字符串相关的代码页。Mu...
由于项目的需要,近期开始学习CUDA。CUDA(Compute Unified Device Architecture),是显卡厂商NVIDIA推出的运算平台。 它是一种由NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。 其包含了CUDA指令集架构(ISA)以及GPU内部的并行计算引擎。 开发人员现在可以使用C语言来为CUDA架构编写程序,C语言是应用最广泛的
更新日期:2021年1月20日。项目源码:在终章发布索引简介正式开始创建行动打开行动编辑器简介本章我们将引入行动编辑器,行动编辑器作为FTG2D的核心功能,游戏核心玩法的70%都将在其中完成!不过,到目前为止我们先不关心它是如何使角色动起来的,我们先了解如何从零开始创建一个行动,以及在行动中我们能够做些什么。正式开始创建行动在Project视图点击右键,选择创建菜单:Create->HTFramework GC->FTG2D->Motion Asset,可以在选定位置创建.
Oracle 11gR2 (Linux版本)百度网盘下载附安装教程