select * from
(
select orgname, max(substr(t2.code_version,1)) CODE_VERSION from
(
SELECT tb_cube_fc05.pk_entity pk_org,/*主体pk*/
org_orgs.code orgcode,/*主体编码*/
org_orgs.name orgname,/*主体名称*/
tb_cube_fc05.pk_year pk_year,/*年份*/
tb_cube_fc05.pk_month pk_month,/*月份*/
tb_cube_fc05.pk_year||'-'||tb_cube_fc05.pk_month period,/*期间*/
sum(nvl(tb_cube_fc05.value,0)) totalcost,/*费用总额*/
tb_cube_fc05.pk_aimcurr pk_currtype,/*币种pk*/
bd_currtype.code currcode,/*币种编码*/
bd_currtype.name currname/*币种名称*/,tb_budgetsub.objname,tb_cube_fc05.code_version,tb_cube_fc05.ts
FROM tb_cube_fc05 tb_cube_fc05 inner join tb_budgetsub tb_budgetsub on tb_budgetsub.pk_obj=tb_cube_fc05.pk_measure
LEFT JOIN tb_dataattr tb_dataattr
ON (tb_cube_fc05.pk_mvtype = tb_dataattr.pk_obj)
LEFT JOIN org_dept org_dept
ON (tb_cube_fc05.pk_entity = org_dept.pk_dept)
LEFT JOIN org_orgs org_orgs
ON (tb_cube_fc05.pk_entity = org_orgs.pk_org)
LEFT JOIN bd_defdoc bd_defdoc
ON (tb_cube_fc05.pk_fc01 = bd_defdoc.pk_defdoc)
left join bd_currtype on bd_currtype.pk_currtype=tb_cube_fc05.pk_aimcurr
where tb_cube_fc05.CODE_MVTYPE='Budget' and tb_dataattr.objname='预算数' and tb_budgetsub.objcode='FC701' --and org_orgs.code='232' --F1169 F1001
-- and substr(tb_cube_fc05.code_version,1) in( select max(substr(code_version,1)) from tb_cube_fc05 )
-- and exists(select ts from (select max(ts) ts from tb_cube_fc05 group by tb_cube_fc05.pk_year ,/*年份*/
-- tb_cube_fc05.pk_month )t where t.ts=tb_cube_fc05.ts)
group by tb_cube_fc05.pk_entity ,/*主体pk*/
org_orgs.code ,/*主体编码*/
org_orgs.name ,/*主体名称*/
tb_cube_fc05.pk_year ,/*年份*/
tb_cube_fc05.pk_month ,/*月份*/
nvl(tb_cube_fc05.value,0) ,/*费用总额*/
tb_cube_fc05.pk_aimcurr ,/*币种pk*/
bd_currtype.code ,/*币种编码*/
bd_currtype.name,tb_budgetsub.objname,tb_cube_fc05.code_version,tb_cube_fc05.ts
)t2 group by t2.orgname --org_orgs.orgname in (select distinct org_orgs.orgname from org_orgs)
)d1
left join
(
SELECT tb_cube_fc05.pk_entity pk_org,/*主体pk*/
org_orgs.code orgcode,/*主体编码*/
org_orgs.name orgname,/*主体名称*/
tb_cube_fc05.pk_year pk_year,/*年份*/
tb_cube_fc05.pk_month pk_month,/*月份*/
tb_cube_fc05.pk_year||'-'||tb_cube_fc05.pk_month period,/*期间*/
sum(nvl(tb_cube_fc05.value,0)) totalcost,/*费用总额*/
tb_cube_fc05.pk_aimcurr pk_currtype,/*币种pk*/
bd_currtype.code currcode,/*币种编码*/
bd_currtype.name currname/*币种名称*/,tb_budgetsub.objname,tb_cube_fc05.code_version,tb_cube_fc05.ts
FROM tb_cube_fc05 tb_cube_fc05 inner join tb_budgetsub tb_budgetsub on tb_budgetsub.pk_obj=tb_cube_fc05.pk_measure
LEFT JOIN tb_dataattr tb_dataattr
ON (tb_cube_fc05.pk_mvtype = tb_dataattr.pk_obj)
LEFT JOIN org_dept org_dept
ON (tb_cube_fc05.pk_entity = org_dept.pk_dept)
LEFT JOIN org_orgs org_orgs
ON (tb_cube_fc05.pk_entity = org_orgs.pk_org)
LEFT JOIN bd_defdoc bd_defdoc
ON (tb_cube_fc05.pk_fc01 = bd_defdoc.pk_defdoc)
left join bd_currtype on bd_currtype.pk_currtype=tb_cube_fc05.pk_aimcurr
where tb_cube_fc05.CODE_MVTYPE='Budget' and tb_dataattr.objname='预算数' and tb_budgetsub.objcode='FC701' --and org_orgs.code='232' --F1169 F1001 -- and exists(select ts from (select max(ts) ts from tb_cube_fc05 group by tb_cube_fc05.pk_year ,/*年份*/
-- tb_cube_fc05.pk_month )t where t.ts=tb_cube_fc05.ts)
group by tb_cube_fc05.pk_entity ,/*主体pk*/
org_orgs.code ,/*主体编码*/
org_orgs.name ,/*主体名称*/
tb_cube_fc05.pk_year ,/*年份*/
tb_cube_fc05.pk_month ,/*月份*/
nvl(tb_cube_fc05.value,0) ,/*费用总额*/
tb_cube_fc05.pk_aimcurr ,/*币种pk*/
bd_currtype.code ,/*币种编码*/
bd_currtype.name,tb_budgetsub.objname,tb_cube_fc05.code_version,tb_cube_fc05.ts
order by org_orgs.name,tb_cube_fc05.pk_month )d2 on d1.orgname=D2.orgname and d1.CODE_VERSION=d2.code_version

另外的解决方案

select * from d2 where d2.orgname|| d2.code_version in 
(select r1.orgname|| r1.code_version from 
(select ) r1
)

select * from d2 where d2.orgname in 
(select r1.orgname from r1) 
and d2.code_version in 
(select r1.code_version from r1)

预算oracle的更多相关文章

  1. Oracle使用经验总结

    oracle数据库是一种大型数据库系统,一般应用于商业,政府部门,它的功能很强大,能够处理大批量的数据,在网络方面也用的非常多.Oracle数据库管理系统是一个以关系型和面向对象为中心管理数据的数据库 ...

  2. Oracle Essbase入门系列(二)

    本篇开始会一个三口之家的家庭财务数据库为例,讲述Essbase的功能和开发.为了说明EPM应用程序的管理和开发过程,会绕一些弯路,不使用EAS,而尽量用EPMA. 创建应用程序 首先登陆到Worksp ...

  3. Oracle与SQL SERVER编程差异分析(入门)

    网上有关Oracle与SQL SERVER性能差异的文章很多,结论往往是让你根据数据量与预算来选择数据库.但实际项目中,特别是使用 .Net 开发的系统,支持以上两种数据库或者更多已经成为Boss的普 ...

  4. GL_GL系列 - 预算管理分析(案例)

    2014-07-09 Created By BaoXinjian

  5. 三分钟读懂Oracle数据库容灾架之DataGuard

    Oracle数据库目前依然处于商用数据库的霸主地位. 运行在Oracle数据库上的核心业务及核心数据的安全性尤为重要. 目前市场上针对Oracle数据库常见的容灾产品大致可以分为两大类. Oracle ...

  6. 在收购Sun六年后,Oracle终于瞄准了Java的非付费用户

    Java语言毫无疑问已经成为软件社区的一个品牌和开放的产业标准.自从2010年Oracle收购了Sun Microsystems公司之后,很多人就担心这在某种程度上是软件开源产业的一次失败,甚至会造成 ...

  7. Oracle RAC学习笔记01-集群理论

    Oracle RAC学习笔记01-集群理论 1.集群相关理论概述 2.Oracle Clusterware 3.Oracle RAC 原理 写在前面: 最近一直在看张晓明的大话Oracle RAC,真 ...

  8. Sun 与 Oracle 合并的未来

    引言 SUN 2008 初 10 亿美元收购 MySQL Oracle 2009 年 4 月 74 亿美元收购 SUN Sun 与 Oracle 合并的未来 1,如果云计算对企业来说变得越来越重要,那 ...

  9. 迎战大数据-Oracle篇

    来自:http://www.cnblogs.com/wenllsz/archive/2012/11/16/2774205.html 了解大数据带来的机遇: 透视架构与工具: 开源节流,获得竞争优势. ...

随机推荐

  1. Solution for latex error:”Unknown graphics extension: .eps“ or "Can not find XXX"

    Sample code: \begin{figure*} \centering % Requires \usepackage{graphicx} \includegraphics[width=7in] ...

  2. Sort--快速排序

    快速排序 1 public class QuickSort{ 2 3 public static int Partition(int[] a,int low,int high){ 4 int pivo ...

  3. leetcode@ [263/264] Ugly Numbers & Ugly Number II

    https://leetcode.com/problems/ugly-number/ Write a program to check whether a given number is an ugl ...

  4. [假期总结]Self

    8月底返校,这一周也没有勤学苦练.假期3周的时间学习了nodejs. 1.nodejs的学习 学习了一本书上的例程,搭建了个博客.这种程度等于是能够动手开发的阶段,前路还很漫长. 2.个人网站的建设 ...

  5. Android NDK r8 windows环境搭建

    Android NDK r8 windows环境搭建 一.默认基础环境为已经完成Android开发环境的搭建 需要的软件及插件 1. JDK-7u25 2. Eclipse 3. Android SD ...

  6. Java文件合并

    文件分割与合并是一个常见需求,比如:上传大文件时,可以先分割成小块,传到服务器后,再进行合并.很多高大上的分布式文件系统(比如:google的GFS.taobao的TFS)里,也是按block为单位, ...

  7. Introduction to DTD

    A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines th ...

  8. [iOS基础控件 - 6.2] LOL英雄列表 UITableView单项显示

    A.需求 1.使用只有一个section的TableView来显示LOL 的英雄列表 2.内容包括标题.副标题.图标 3.使用plain样式 4.使用MVC模式     heros.plist 文件结 ...

  9. [Objective-c 基础 - 1.3] OC带返回值的类方法

    /* 计算器类 1>返回π 2>计算两个整数的平方 3>计算两个整数的和 */ #import <Foundation/Foundation.h> @interface ...

  10. .Net 项目常见疑难杂症

    1.A项目引用 B项目 B项目引用C.dll 同时 A也必须引用 C.dll 则 A中引用的C的版本 必须和 B中引用C的版本相同 否则就会出现下面这类问题:解决办法 :同步A B项目中引用C的版本一 ...