- 浏览: 2473833 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (574)
- Book (62)
- Architecture (6)
- Java (39)
- Taobao (41)
- Distributed (4)
- Life (72)
- Database (7)
- Spring (16)
- Photography (15)
- Bicycle (41)
- Test (20)
- jBPM (8)
- Business (12)
- Movie (3)
- Ajax (15)
- Code (7)
- Eclipse (96)
- VIM (2)
- Music (6)
- Groovy (10)
- AutoHotKey (3)
- Dorado (10)
- Maven (7)
- Scrum (5)
- English (20)
- Financial (12)
- OSGi (3)
- Other (4)
- Tool (6)
- Browser (1)
- PPT (1)
- Project Management (4)
- Agile (6)
- Nosql (1)
- Search engine (6)
- Shell (2)
- Open Source (4)
- Storm (10)
- Guava (3)
- Baby (1)
- netty (1)
- Algorithm (1)
- Linux (1)
- Python (2)
最新评论
-
roy2011a:
https://github.com/ebottabi/sto ...
storm的序列化问题及与spring的结合方式 -
roy2011a:
能抗能打 写道哥们儿,你好!能共享下那个storm与sprin ...
storm的序列化问题及与spring的结合方式 -
Alick1:
兄弟,你之前是不是在深圳的正阳公司呆过啊?
storm的ack和fail -
liuleixwd:
先点个赞,写的非常好!有个问题请教下,如果我再bolt里不用e ...
storm的ack和fail -
yao-dd:
solr的facet查询
1.这个是交叉表的应用, 用于统计分析报表
2.这个是一个存储函数, 比较简单, 主要是oracle中connect by prior start with的用法
3.用一个字段做累加计算找余额
4.union的使用
4.这个是连接的使用(target中的左右连接比较复杂)
5.这个也是union加聚合函数sum的使用, 用来将两类数据分组为两大类, 然后每一类是一列
select entity_.*, entity_.field3 + entity_.field4 + entity_.field5 + entity_.field6 + entity_.field7 + entity_.field8 + entity_.field9 as sum_maintain, entity_.field1 + entity_.field2 + entity_.field3 + entity_.field4 + entity_.field5 + entity_.field6 + entity_.field7 + entity_.field8 + entity_.field9 + entity_.field10 as sum_all from (select result_.id, result_.name, sum(case result_.type_id when 1 then -- 固定费用(一级) amount when 5 then -- 复印打印(二级) amount when 6 then -- 办公用品(二级) amount when 7 then -- 运费(二级) amount when 8 then -- 汇款手续费(二级) amount when 9 then -- 邮寄费(二级) amount else 0 end) field1, -- 固定费用, sum(case result_.type_id when 2 then -- 差旅费(一级) amount when 10 then -- 通讯费(二级) amount when 11 then -- 业务招待费(二级) amount when 12 then -- 车辆使用费(二级) amount when 13 then -- 房租(二级) amount when 14 then -- 差旅车票(二级) amount when 15 then -- 住宿费(二级) amount else 0 end) field2, -- 差旅费, sum(case result_.type_id when 16 then amount else 0 end) field3, -- 临聘人员奖励提成费, sum(case result_.type_id when 17 then amount else 0 end) field4, -- 促销礼品费, sum(case result_.type_id when 18 then amount else 0 end) field5, -- 展示特陈费, sum(case result_.type_id when 19 then amount else 0 end) field6, -- 茶友会活动费, sum(case result_.type_id when 20 then amount else 0 end) field7, -- 新品进场费, sum(case result_.type_id when 21 then amount else 0 end) field8, -- 店员奖励, sum(case result_.type_id when 22 then amount else 0 end) field9, -- 终端客情费 sum(case result_.type_id when 4 then amount else 0 end) field10 --奖金 from (select detail_.*, s.groupname as name from (select d.type_id, d.amount, get_salagroup_id(:salegroupid, d.employee_id) as id from ch_process_form pf, ch_process_form_item_detail d where d.form_id = pf.id and (pf.process_type = :processType1 -- 拨付申请 or pf.process_type = :processType2) -- 报销申请 and pf.process_state != 4 -- 去掉被取消的 and (pf.process_state = :state or :state = -1) and to_char(pf.create_date, 'yyyy-mm-dd hh24:mi:ss') >= :start_ and to_char(pf.create_date, 'yyyy-mm-dd hh24:mi:ss') <= :end_) detail_, zx_dm_salegroup s where detail_.id = s.salegroupid and detail_.id != 0) result_ -- 0表示统计的detail的使用employee不在当前的区域 group by result_.id, result_.name) entity_
2.这个是一个存储函数, 比较简单, 主要是oracle中connect by prior start with的用法
create or replace function GET_SALAGROUP_ID1(topgroupid in number, accountid in number) -- 根据给定的账户id找到对应的最上级辖区id, 且该辖区id必须小于给定的topgroupid return number is Result number; cursor c1 is select min(s.salegroupid) from zx_dm_salegroup s connect by prior s.managegroupid = s.salegroupid -- 由子找父 and s.salegroupid != topgroupid -- 给定向上找的限定条件 start with s.salegroupid = (select es.salegroupid from zx_dm_employee_sale es, ch_account_employee ae, ch_account a where es.employeeid = ae.employee_id and ae.main_id = a.main_id and a.id = accountid); -- 取得对应帐号的辖区id begin open c1; fetch c1 into result; close c1; return(Result); end GET_SALAGROUP_ID1;
3.用一个字段做累加计算找余额
select remain_.code_id, --费用帐号 remain_.type_id, remain_.type_name, current_.amount, -- 当前申请核销金额 proposal_.amount as proposal_amount, --当前申请拨付金额 payment_.amount + nvl(current_.amount, 0) as enable_amount, -- 可用核销余额 remain_.remain + nvl(proposal_.amount, 0) as enable_remain, -- 可用费用余额 remain_.remain as sum_amount -- 费用总额 from (select ct.id as type_id, ct.type_name, max_.id, max_.code_id, cd.remain - nvl(freeze_.amount, 0) as remain from ch_code_deal cd, ch_charge_type ct, ch_code c, (select max(cd.id) as id, c.id as code_id from ch_code c, ch_code_deal cd where c.account_id = (select a2.id from ch_account a1, ch_account a2 where a1.id = :accountId and a2.main_id = a1.main_id and a2.account_type = 1) and cd.code_id = c.id group by c.id) max_, -- 从最后一条交易记录中取出帐号的费用余额 (select cf.code_id, sum(cf.amount) as amount from ch_code_freeze cf where cf.freeze_flag = 1 group by cf.code_id) freeze_ -- 处理中(被冻结)的费用 where cd.id = max_.id and cd.code_id = c.id and c.type_id = ct.id and cd.code_id = freeze_.code_id(+)) remain_, -- 取出账户的费用余额 (select i.type_id, i.amount - nvl(certi_.amount, 0) as amount from ch_process_form_item i, (select i.type_id, sum(i.amount) amount from ch_process_form_item i, ch_process_form f where f.parent_id = :parentFormId and i.form_id = f.id and f.process_type = :processTypeId and f.process_state != 4 --去掉被取消的 group by i.type_id) certi_ -- 已经核销的部分 where i.form_id = :parentFormId and i.type_id = certi_.type_id(+)) payment_, -- 可用核销金额 (select type_id, code_id, amount from ch_process_form_item where form_id = :proposalFormId) proposal_, -- 当前拨付申请 (select type_id, code_id, amount from ch_process_form_item where form_id = :formId) current_ -- 当前核销申请 where remain_.type_id = current_.type_id(+) and remain_.type_id = payment_.type_id(+) and remain_.type_id = proposal_.type_id(+) and payment_.amount + nvl(current_.amount, 0) > 0
4.union的使用
select form_.account_id, form_.account_name, ct.id type_id, ct.type_name, sum(expense_remain) expense_remain, sum(expense_freeze_amount) expense_freeze_amount, sum(expense_enable_amount) expense_enable_amount, sum(fund_remain) fund_remain, sum(fund_freeze_amount) fund_freeze_amount, sum(fund_enable_amount) fund_enable_amount from (select a.id as account_id, a.name as account_name, ae.employee_id, t.id type_id, remain_.remain as expense_remain, freeze_.amount as expense_freeze_amount, remain_.remain - nvl(freeze_.amount, 0) expense_enable_amount, null fund_remain, null fund_freeze_amount, null fund_enable_amount from ch_code c, ch_account a, ch_account_employee ae, ch_charge_type t, (select d.code_id, d.remain from ch_code_deal d, (select d.code_id, max(d.id) as id from ch_code_deal d group by d.code_id) last_ where d.id = last_.id) remain_, --余额 (select f.code_id, sum(f.amount) as amount from ch_code_freeze f, ch_account a where f.account_id = a.id and a.account_type = 1 and f.freeze_flag = 1 -- 费用冻结 group by f.code_id) freeze_ -- 费用账户金额 where c.id = remain_.code_id(+) and c.id = freeze_.code_id(+) and c.account_id = a.id and a.account_type = 1 and a.main_id = ae.main_id and c.type_id = t.id and remain_.remain is not null union select a.id as account_id, a.name as account_name, ae.employee_id, t.id type_id, null expense_remain, null expense_freeze_amount, null expense_enable_amount, remain_.remain fund_remain, freeze_.amount fund_freeze_amount, remain_.remain - nvl(freeze_.amount, 0) fund_enable_amount from ch_code c, ch_account a, ch_account_employee ae, ch_charge_type t, (select d.code_id, d.remain from ch_code_deal d, (select d.code_id, max(d.id) as id from ch_code_deal d group by d.code_id) last_ where d.id = last_.id) remain_, (select f.code_id, sum(f.amount) as amount from ch_code_freeze f, ch_account a where f.account_id = a.id and a.account_type = 2 and f.freeze_flag = 3 -- 核销冻结 group by f.code_id) freeze_ -- 资金账户金额 where c.id = remain_.code_id(+) and c.id = freeze_.code_id(+) and c.account_id = a.id and a.account_type = 2 and a.main_id = ae.main_id and c.type_id = t.id and remain_.remain is not null) form_, ch_charge_type ct where ct.id = form_.type_id and form_.account_name like :accountName
4.这个是连接的使用(target中的左右连接比较复杂)
select source_.*, target_.target_enable_remain, target_.target_sum_amount from (select last_.code_id, last_.type_id, last_.type_name, current_.amount as amount, -- 申请金额 auditing_.amount as auditing_amount, -- 在批金额 nvl(last_.remain, 0) - nvl(paying_.amount, 0) as enable_remain -- 可用余额 from (select cd.code_id, cd.remain, c.type_id, c.type_name from ch_code_deal cd, (select c.id, t.id type_id, t.type_name from ch_code c, ch_account a, ch_charge_type t where a.id = :sourceAccountId and c.account_id = a.id and c.enable_flag = 1 and c.type_id = t.id and t.enable_flag = 1) c, (select max(cd.id) as id from ch_code_deal cd group by cd.code_id) max_ -- 支出方费用帐号余额 where cd.id = max_.id and cd.code_id = c.id) last_, (select cf.code_id, sum(cf.amount) amount from ch_code_freeze cf where cf.account_id = :sourceAccountId and cf.process_type = :processType and cf.form_id != :formId group by cf.code_id) auditing_, --在批金额 (select cf.code_id, sum(cf.amount) amount from ch_code_freeze cf where cf.account_id = :sourceAccountId and cf.freeze_flag = 1 -- 在拨申请中 group by cf.code_id) paying_, --拨付申请金额 (select i.code_id, i.amount from ch_process_form_item i where form_id = :formId) current_ where last_.code_id = auditing_.code_id(+) and last_.code_id = paying_.code_id(+) and last_.code_id = current_.code_id(+)) source_, --支出帐号信息 (select last_.code_id, last_.type_id, nvl(last_.remain, 0) - nvl(paying_.amount, 0) as target_enable_remain, -- 可用余额 nvl(last_.remain, 0) as target_sum_amount -- 费用总额 from (select c.id code_id, c.type_id, cd.remain from ch_code_deal cd, (select c.id, t.id type_id from ch_code c, ch_account a, ch_charge_type t where a.id = :targetAccountId and c.account_id = a.id and c.enable_flag = 1 and c.type_id = t.id and t.enable_flag = 1) c, (select max(cd.id) as id from ch_code_deal cd group by cd.code_id) max_ where cd.id = max_.id(+) and cd.code_id(+) = c.id) last_, (select cf.code_id, sum(cf.amount) amount from ch_code_freeze cf where cf.account_id = :targetAccountId and cf.freeze_flag = 1 -- 拨付申请中 group by cf.code_id) paying_ -- 拨付申请金额 where last_.code_id = paying_.code_id(+)) target_ -- 接收帐号信息 where source_.type_id = target_.type_id
5.这个也是union加聚合函数sum的使用, 用来将两类数据分组为两大类, 然后每一类是一列
select form_.main_id, e_.employeeid, e_.employeename, form_.type_id, ct.type_name, sum(expense_remain) expense_remain, -- 这里必须使用sum来聚合一下, 否则费用和资金的金额将不会合并, 记录集会增加一倍 sum(expense_freeze_amount) expense_freeze_amount, sum(expense_enable_remain) expense_enable_remain, sum(fund_remain) fund_remain, sum(fund_freeze_amount) fund_freeze_amount, sum(fund_enable_remain) fund_enable_remain from (select ae.main_id, ae.employee_id, remain_.type_id, remain_.remain as expense_remain, freeze_.amount as expense_freeze_amount, remain_.remain - nvl(freeze_.amount, 0) expense_enable_remain, null fund_remain, null fund_freeze_amount, null fund_enable_remain from ch_account_employee ae, (select d.code_id, c.type_id, a.main_id, d.remain, max(d.id) from ch_code_deal d, ch_account a, ch_code c where d.code_id = c.id and c.account_id = a.id and a.account_type = 1 group by d.code_id, c.type_id, a.main_id, d.remain) remain_, --余额 (select f.code_id, sum(f.amount) as amount from ch_code_freeze f, ch_account a where f.account_id = a.id and a.account_type = 1 and f.freeze_flag = 1 group by f.code_id) freeze_ -- 待拨费用 where remain_.code_id = freeze_.code_id(+) and remain_.main_id = ae.main_id union select ae.main_id, ae.employee_id, remain_.type_id, null expense_remain, null expense_freeze_amount, null expense_enable_remain, remain_.remain fund_remain, freeze_.amount fund_freeze_amount, remain_.remain - nvl(freeze_.amount, 0) fund_enable_remain from ch_account_employee ae, (select d.code_id, c.type_id, a.main_id, d.remain, max(d.id) from ch_code_deal d, ch_account a, ch_code c where d.code_id = c.id and c.account_id = a.id and a.account_type = 2 group by d.code_id, c.type_id, a.main_id, d.remain) remain_, (select f.code_id, sum(f.amount) as amount from ch_code_freeze f, ch_account a where f.account_id = a.id and a.account_type = 2 and f.freeze_flag = 3 -- 核销冻结 group by f.code_id) freeze_ -- 资金账户金额 where remain_.code_id = freeze_.code_id(+) and remain_.main_id = ae.main_id) form_, ch_charge_type ct, zx_dm_employee e_ where ct.id = form_.type_id and e_.employeeid = form_.employee_id and e_.employeename like ? group by form_.main_id, e_.employeeid, e_.employeename, form_.type_id, ct.type_name
发表评论
-
遭遇数据库并发问题
2010-06-10 22:01 2390最近碰到一个数据库并发的问题, 觉得是一个很有意义的经验教训, ... -
svn资料备忘
2009-03-23 17:58 2057Subversion(SVN) 是一个版本管理软件或者服务器, ... -
VI学习笔记
2009-01-17 10:53 1943移动 : · h、j、k和l键将 ... -
一个不错的taobao viso flow shape
2009-01-12 10:48 1328taobao viso flow shape -
ibatis中的resultMap如何继承
2008-12-11 08:44 9581<typeAlias alias="Dom ... -
docbook使用心得
2008-10-19 19:14 2848最近开始用docbook写文档, 这里有一篇前人的< ... -
电话面试收集
2008-09-24 10:05 3624对求职者求职信和简历上的内容进行重新的确认,看看是否有漏洞,是 ... -
必须掌握的8个dos命令
2008-08-03 21:11 1489一,ping 它是用来检查网络是否通畅或者网络连接速度 ... -
PL SQL学习笔记(未完)
2008-07-17 18:09 2403sql属于第三代语言, 也 ... -
Remedy AR System学习笔记
2007-10-25 09:52 6421Remedy AR System组成 Remedy AR Sy ... -
ITIL,ITSM学习笔记
2007-09-26 14:31 5669为了做好联通的Remedy项 ...
相关推荐
在SQL(Structured Query Language)中,存储过程是预编译的SQL语句集合,它封装了数据库中的复杂操作,可以被多次调用,提供了一种更高效、安全且易于维护的方式来执行数据库操作。标题和描述中提到的"一个项目的...
【描述】"sql版易买网 个人手工打造 如有雷同 纯属盗版 北大青鸟二期结业项目"这段描述揭示了几个关键点: 1. **SQL版易买网**:这里提到的“SQL版”表明该项目是围绕数据库管理和查询语言SQL构建的,可能涉及到...
1. **SQL日志打印**:插件会在日志中详细输出每个SQL语句,包括原始的SQL模板、实际的参数值以及执行后的结果,这对于理解代码与数据库交互的情况非常有帮助。 2. **执行时间统计**:MybatisX还提供了SQL执行时间的...
在这个"C#+SQL Server项目开发实践"中,我们可以学习到以下几个关键知识点: 1. C#基础:包括变量、数据类型、控制结构(如条件语句、循环)、函数、类和对象等。这些都是编写任何C#程序的基础。 2. .NET ...
在电信计费系统中,SQL主要用于以下几个关键知识点: 1. 数据库设计:SQL用于创建和管理关系型数据库,如定义表结构、设置字段类型、主键和外键等。在电信计费项目中,可能涉及用户信息表、通话记录表、费用明细表...
在本Java+SQL实训项目中,我们关注的核心是利用JSP(Java Server Pages)技术和SQL数据库来构建一个机票购买系统。这个系统旨在提供一个安全、稳定的服务,让用户能够方便地在线购买机票。以下是对该项目各个方面的...
标签是Mabits动态SQL中最常用的一个标签之一,它的作用是根据给定条件包含或排除不同的部分,以生成不同的SQL语句。在XML文件中,标签通常被嵌套在其他标签内,如、和等标签内,用于控制生成的SQL语句的结构和内容。...
在"C# + SQL Server项目开发实践"中,我们探讨了如何使用C#编程语言与Microsoft SQL Server数据库系统相结合,来构建高效、稳定的业务应用程序。这个主题涵盖了教务管理系统和人力资源管理系统等多个实际应用场景,...
在你的"项目sql及文件"压缩包中,显然包含了一个名为"DORMMS"的子文件夹,这可能是代表“Database ORM Management System”(数据库对象关系映射管理系统)或者某种特定项目的代码库。ORM(Object-Relational ...
在提供的压缩包文件"WINCC读写SQL数据库的示例"中,你将找到一个完整的WinCC项目,其中包含了上述概念的实际应用。通过研究这个项目,你可以更直观地学习如何在WinCC中编写和运行VBScript,以及如何与SQL Server...
首先,要实现C#执行SQL文件,我们需要了解几个关键的概念和技术: 1. **ADO.NET**: .NET Framework中的数据访问组件,它为开发者提供了与数据库交互的接口,如SqlConnection、SqlCommand等类。 2. **SqlConnection...
解决这个问题的方法分为几个步骤: 1. **确认数据库编码**:确保你知道SQL Server数据库的字符集,例如,确认它是GBK编码。 2. **检查PHP脚本编码**:了解你的PHP脚本文件的编码,例如,确认它们是UTF-8编码。 3. *...
本篇将详细介绍如何利用日志来调试Ibatis中的复杂SQL动态拼接。 首先,了解Ibatis的日志系统是关键。Ibatis默认集成了几种常见的日志实现,如Log4j、Logback和Java内置的日志框架。在项目中,我们需要配置相应的...
在“谷粒商城”这个项目中,SQL脚本将用于以下几个核心方面: 1. **数据库设计**:首先,SQL脚本会定义各个数据表的结构,包括表名、字段名、字段类型、主键、外键等。例如,可能会有用户表(users)、商品表...
【标题】"收集的几个MyEclipse+SQL网站开发源码"所涵盖的知识点主要集中在MyEclipse集成开发环境和SQL数据库技术在网站开发中的应用。MyEclipse是一款强大的Java集成开发工具,常用于企业级Web应用的开发,它基于...
在SQL Server数据库中,成批导入数据是一项常见的需求,尤其在软件项目实施过程中,大量数据的迁移至关重要。本文将介绍几种常用的SQL Server批量导入数据的方法。 首先,使用`SELECT INTO`语句是一种直接且简单的...
│ │ 5.1.1 SET IDENTITY_INSERT 中的几个问题.sql │ │ 5.1.1 修改标识值的示例.sql │ │ 5.1.1 标识列与普通列互相转换的示例.sql │ │ 5.2.1 查表法按日期生成流水号的示例.sql │ │ 5.2.1 查表法生成流水号...
具体包括以下几个核心知识点: 1. **ASP.NET 2.0控件**:了解各种服务器控件,如Label、TextBox、Button等,以及如何使用它们来构建交互式表单。 2. **数据绑定**:掌握DataSource控件的使用,包括SqlDataSource、...
总结,Spring Boot整合Mybatis连接SQL Server进行跨库批量插入,主要涉及以下几个步骤: 1. 添加相关依赖。 2. 配置数据库连接信息。 3. 创建Mapper接口和XML文件,定义跨库插入的SQL语句。 4. 在Service层调用...
在学习这个项目时,你需要关注以下几个重点: 1. 系统架构设计:了解netctoss如何组织模块,各模块间的交互方式。 2. 数据库设计:分析SQL脚本,理解电信业务的关键数据模型。 3. 业务逻辑:通过源码阅读理解核心...