- 浏览: 49111 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
JYY282:
不错的推荐。为我这个新人指路了。
转javascript书籍推荐 -
zhoutong123a:
好东西,谢谢
jquery 可编辑的表格 -
zhangpurple:
...
jquery 可编辑的表格 -
shuiwangxing:
运行这个插件的时候,老是报404的错误
Struts2+json+jQuery(用户名验证) -
lsh4894:
struts2-json-plugin-2.2.3.jar 哪 ...
Struts2+json+jQuery(用户名验证)
数据库数据:
teamName | userName | monthIncome |
A | 111 | 60 |
A | 222 | 90 |
B | 333 | 100 |
B | 444 | 50 |
select
case userName when '小 计' then '小 计' else teamName end teamName,
case userName when '小 计' then '' else userName end userName,
monthIncome
from (
select 0 ordersn, teamName, userName, monthIncome from table
union
select 1 ordersn, teamName, '小 计' userName, sum(monthIncome) monthIncome \
group by teamName
)
order by ordersn, teamName
参考:
select case userName when '小 计' then '小 计' else team_Name end teamName, userId, case userName when '小 计' then '' else userName end userName, brokerLevel, adjustDraftLevel, adjustDraftResult, draftLevel, draftResult, ifReport, detailRemark, branchCode, capital, capitalDaily, tranMoneyTotal, actualFeeTotal, netFeeTotal, netFeeConvertTotal, netFeeSum, netFeeMonthly, trunc(validCust) validCust, trunc(netValidCust) netValidCust, trunc(netValidCustConvert) netValidCustConvert, trunc( netValidCustSum) netValidCustSum, trunc(netValidCustMonthly) netValidCustMonthly from ( <!-- 团队成员--> <!--nvl(utr.team_name,'团队名称')目的是防止为空 导出excel判断相同单元格合并报错 --> select 1 ordersn, 0 orderno, nvl(utr.team_name,'团队名称') team_name,u.user_id userId,u.username userName, pd.START_LEVEL brokerLevel, PADJ.adjusted_level adjustDraftLevel, pd.draft_level draftLevel, PADJ.adjusted_result adjustDraftResult, pd.draft_result draftResult, pd.if_report ifReport, PADJ.ADJUSTED_REMARK detailRemark, PR.BRANCH_CODE branchCode, to_char(nvl((pd.capital),0),'99999999999999990.99') capital, to_char(nvl((pd.capital_daily),0),'99999999999999990.99') capitalDaily, to_char(nvl(( pd.tran_money_total),0),'99999999999999990.99') tranMoneyTotal, to_char(nvl((pd.actual_fee_total),0),'99999999999999990.99') actualFeeTotal, to_char(nvl((pd.net_fee_total),0),'99999999999999990.99') netFeeTotal, to_char(nvl((pd.net_fee_convert_total),0),'99999999999999990.99') netFeeConvertTotal, to_char(nvl(( pd.net_fee_sum),0),'99999999999999990.99') netFeeSum, to_char(nvl(( pd.net_fee_monthly),0),'99999999999999990.99') netFeeMonthly, to_char(nvl(( pd.valid_cust),0),'99999999999999990.99') validCust, to_char(nvl(( pd.net_valid_cust),0),'99999999999999990.99') netValidCust, to_char(nvl(( pd.net_valid_cust_convert),0),'99999999999999990.99') netValidCustConvert, to_char(nvl((pd.net_valid_cust_sum),0),'99999999999999990.99') netValidCustSum, to_char(nvl(( pd.net_valid_cust_monthly),0),'99999999999999990.99') netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id left join KH.TB_KH_PERSONAL_ADJUSTED PADJ on pd.p_detail_id=PADJ.p_detail_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' inner join (select utr.user_id,ut.team_id,ut.team_name from kh.tb_snap_user_team_rel utr inner join kh.tb_snap_user_team ut on utr.team_id = ut.team_id and ut.team_sts = 0 where utr.member_type=0 and utr.status = 0) utr on u.user_id = utr.user_id where u.user_type=0 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' union <!--团队小计--> select 1 ordersn, 1 orderno, utr.team_name,null userId,'小 计' userName, null brokerLevel, '' adjustDraftLevel, '' draftLevel, '' adjustDraftResult, '' draftResult , '' ifReport, '' detailRemark, PR.BRANCH_CODE branchCode, to_char(nvl(sum(to_char(pd.capital,'99999999999999990.99')),0)) capital, to_char( nvl(sum(to_char(pd.capital_daily,'99999999999999990.99')),0)) capitalDaily, to_char(nvl(sum(to_char( pd.tran_money_total,'99999999999999990.99')),0)) tranMoneyTotal, to_char( nvl(sum(to_char(pd.actual_fee_total,'99999999999999990.99')),0)) actualFeeTotal, to_char( nvl(sum(to_char(pd.net_fee_total,'99999999999999990.99')),0)) netFeeTotal, to_char(nvl(sum(to_char(pd.net_fee_convert_total,'99999999999999990.99')),0)) netFeeConvertTotal, to_char(nvl(sum(to_char( pd.net_fee_sum,'99999999999999990.99')),0)) netFeeSum, to_char(nvl(sum(to_char( pd.net_fee_monthly,'99999999999999990.99')),0)) netFeeMonthly, to_char(nvl(sum(to_char( pd.valid_cust,'99999999999999990.99')),0)) validCust, to_char( nvl(sum(to_char( pd.net_valid_cust ,'99999999999999990.99')),0)) netValidCust, to_char(nvl(sum(to_char( pd.net_valid_cust_convert,'99999999999999990.99')),0)) netValidCustConvert, to_char(nvl(sum(to_char(pd.net_valid_cust_sum,'99999999999999990.99')),0)) netValidCustSum, to_char(nvl(sum(to_char( pd.net_valid_cust_monthly,'99999999999999990.99')),0)) netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' inner join ( select utr.user_id,ut.team_id,ut.team_name from kh.tb_snap_user_team_rel utr inner join kh.tb_snap_user_team ut on utr.team_id = ut.team_id and ut.team_sts = 0 where utr.member_type=0 and utr.status = 0) utr on u.user_id = utr.user_id where u.user_type=0 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' group by PR.BRANCH_CODE, utr.team_name union <!--非团队成员--> select 2 ordersn, 0 orderno, '非团队成员' as team_Name, u.user_id userId , u.username userName, pd.START_LEVEL brokerLevel, PADJ.adjusted_level adjustDraftLevel, pd.draft_level draftLevel, PADJ.adjusted_result adjustDraftResult, pd.draft_result draftResult, pd.if_report ifReport, PADJ.ADJUSTED_REMARK detailRemark, PR.BRANCH_CODE branchCode, to_char(nvl((pd.capital),0),'99999999999999990.99') capital, to_char(nvl((pd.capital_daily),0),'99999999999999990.99') capitalDaily, to_char(nvl(( pd.tran_money_total),0),'99999999999999990.99') tranMoneyTotal, to_char(nvl((pd.actual_fee_total),0),'99999999999999990.99') actualFeeTotal, to_char(nvl((pd.net_fee_total),0),'99999999999999990.99') netFeeTotal, to_char(nvl((pd.net_fee_convert_total),0),'99999999999999990.99') netFeeConvertTotal, to_char(nvl(( pd.net_fee_sum),0),'99999999999999990.99') netFeeSum, to_char(nvl(( pd.net_fee_monthly),0),'99999999999999990.99') netFeeMonthly, to_char(nvl(( pd.valid_cust),0),'99999999999999990.99') validCust, to_char(nvl(( pd.net_valid_cust),0),'99999999999999990.99') netValidCust, to_char(nvl(( pd.net_valid_cust_convert),0),'99999999999999990.99') netValidCustConvert, to_char(nvl((pd.net_valid_cust_sum),0),'99999999999999990.99') netValidCustSum, to_char(nvl(( pd.net_valid_cust_monthly),0),'99999999999999990.99') netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id left join KH.TB_KH_PERSONAL_ADJUSTED PADJ on pd.p_detail_id=PADJ.p_detail_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' left join ( select utr.user_id from kh.tb_snap_user_team_rel utr inner join kh.tb_snap_user_team ut on utr.team_id = ut.team_id and ut.team_sts = 0 where utr.status = 0) utr on u.user_id = utr.user_id where utr.user_id is null and u.user_type=0 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' union <!--非团队成员小计--> select 2 ordersn, 1 orderno, '非团队成员' as team_Name,null userId,'小 计' userName, null brokerLevel, '' adjustDraftLevel, '' draftLevel, '' adjustDraftResult, '' draftResult , '' ifReport, '' detailRemark, PR.BRANCH_CODE branchCode, to_char( nvl(sum(to_char(pd.capital,'99999999999999990.99')),0)) capital, to_char( nvl(sum(to_char(pd.capital_daily,'99999999999999990.99')),0)) capitalDaily, to_char( nvl(sum(to_char( pd.tran_money_total,'99999999999999990.99')),0)) tranMoneyTotal, to_char(nvl(sum(to_char(pd.actual_fee_total,'99999999999999990.99')),0)) actualFeeTotal, to_char( nvl(sum(to_char(pd.net_fee_total,'99999999999999990.99')),0)) netFeeTotal, to_char( nvl(sum(to_char(pd.net_fee_convert_total,'99999999999999990.99')),0)) netFeeConvertTotal, to_char( nvl(sum(to_char( pd.net_fee_sum,'99999999999999990.99')),0)) netFeeSum, to_char( nvl(sum(to_char( pd.net_fee_monthly,'99999999999999990.99')),0)) netFeeMonthly, to_char( nvl(sum(to_char( pd.valid_cust,'99999999999999990.99')),0)) validCust, to_char(nvl(sum(to_char( pd.net_valid_cust ,'99999999999999990.99')),0)) netValidCust, to_char( nvl(sum(to_char( pd.net_valid_cust_convert,'99999999999999990.99')),0)) netValidCustConvert, to_char(nvl(sum(to_char(pd.net_valid_cust_sum,'99999999999999990.99')),0)) netValidCustSum, to_char( nvl(sum(to_char( pd.net_valid_cust_monthly,'99999999999999990.99')),0)) netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' left join ( select utr.user_id from kh.tb_snap_user_team_rel utr inner join kh.tb_snap_user_team ut on utr.team_id = ut.team_id and ut.team_sts = 0 where utr.status = 0) utr on u.user_id = utr.user_id where utr.user_id is null and u.user_type=0 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' group by PR.BRANCH_CODE, null union <!--业务部--> select 3 ordersn, 0 orderno, '业务部' as team_Name, u.user_id userId, u.username userName, pd.START_LEVEL brokerLevel, PADJ.adjusted_level adjustDraftLevel, pd.draft_level draftLevel, PADJ.adjusted_result adjustDraftResult, pd.draft_result draftResult, pd.if_report ifReport, PADJ.ADJUSTED_REMARK detailRemark, PR.BRANCH_CODE branchCode, to_char(nvl((pd.capital),0),'99999999999999990.99') capital, to_char(nvl((pd.capital_daily),0),'99999999999999990.99') capitalDaily, to_char(nvl(( pd.tran_money_total),0),'99999999999999990.99') tranMoneyTotal, to_char(nvl((pd.actual_fee_total),0),'99999999999999990.99') actualFeeTotal, to_char(nvl((pd.net_fee_total),0),'99999999999999990.99') netFeeTotal, to_char(nvl((pd.net_fee_convert_total),0),'99999999999999990.99') netFeeConvertTotal, to_char(nvl(( pd.net_fee_sum),0),'99999999999999990.99') netFeeSum, to_char(nvl(( pd.net_fee_monthly),0),'99999999999999990.99') netFeeMonthly, to_char(nvl(( pd.valid_cust),0),'99999999999999990.99') validCust, to_char(nvl(( pd.net_valid_cust),0),'99999999999999990.99') netValidCust, to_char(nvl(( pd.net_valid_cust_convert),0),'99999999999999990.99') netValidCustConvert, to_char(nvl((pd.net_valid_cust_sum),0),'99999999999999990.99') netValidCustSum, to_char(nvl(( pd.net_valid_cust_monthly),0),'99999999999999990.99') netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id left join KH.TB_KH_PERSONAL_ADJUSTED PADJ on pd.p_detail_id=PADJ.p_detail_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' where u.user_type=4 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' union <!--业务部小计--> select 3 ordersn, 1 orderno, '业务部' as team_Name,null userId,'小 计' userName, null brokerLevel, '' adjustDraftLevel, '' draftLevel, '' adjustDraftResult, '' draftResult , '' ifReport, '' detailRemark, PR.BRANCH_CODE branchCode, to_char(nvl(sum(to_char(pd.capital,'99999999999999990.99')),0)) capital, to_char(nvl(sum(to_char(pd.capital_daily,'99999999999999990.99')),0)) capitalDaily, to_char(nvl(sum(to_char( pd.tran_money_total,'99999999999999990.99')),0)) tranMoneyTotal, to_char(nvl(sum(to_char(pd.actual_fee_total,'99999999999999990.99')),0)) actualFeeTotal, to_char(nvl(sum(to_char(pd.net_fee_total,'99999999999999990.99')),0)) netFeeTotal, to_char(nvl(sum(to_char(pd.net_fee_convert_total,'99999999999999990.99')),0)) netFeeConvertTotal, to_char(nvl(sum(to_char( pd.net_fee_sum,'99999999999999990.99')),0)) netFeeSum, to_char(nvl(sum(to_char( pd.net_fee_monthly,'99999999999999990.99')),0)) netFeeMonthly, to_char(nvl(sum(to_char( pd.valid_cust,'99999999999999990.99')),0)) validCust, to_char(nvl(sum(to_char( pd.net_valid_cust ,'99999999999999990.99')),0)) netValidCust, to_char(nvl(sum(to_char( pd.net_valid_cust_convert,'99999999999999990.99')),0)) netValidCustConvert, to_char(nvl(sum(to_char(pd.net_valid_cust_sum,'99999999999999990.99')),0)) netValidCustSum, to_char(nvl(sum(to_char( pd.net_valid_cust_monthly,'99999999999999990.99')),0)) netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' where u.user_type=4 and u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' group by PR.BRANCH_CODE, null union <!--总合 计--> select 4 ordersn, 0 orderno, '总合计' as team_Name, null userId ,'' username, null brokerLevel, '' adjustDraftLevel, '' draftLevel, '' adjustDraftResult, '' draftResult , '' ifReport, '' detailRemark, to_char(u.dept_id) branchCode, to_char(nvl(sum(to_char(capital,'99999999999999990.99')),0)) capital, to_char(nvl(sum(to_char(pd.capital_daily,'99999999999999990.99')),0)) capitalDaily, to_char(nvl(sum(to_char( pd.tran_money_total,'99999999999999990.99')),0)) tranMoneyTotal, to_char(nvl(sum(to_char(pd.actual_fee_total,'99999999999999990.99')),0)) actualFeeTotal, to_char(nvl(sum(to_char(pd.net_fee_total,'99999999999999990.99')),0)) netFeeTotal, to_char(nvl(sum(to_char(pd.net_fee_convert_total,'99999999999999990.99')),0)) netFeeConvertTotal, to_char(nvl(sum(to_char( pd.net_fee_sum,'99999999999999990.99')),0)) netFeeSum, to_char(nvl(sum(to_char( pd.net_fee_monthly,'99999999999999990.99')),0)) netFeeMonthly, to_char(nvl(sum(to_char( pd.valid_cust,'99999999999999990.99')),0)) validCust, to_char(nvl(sum(to_char( pd.net_valid_cust ,'99999999999999990.99')),0)) netValidCust, to_char(nvl(sum(to_char( pd.net_valid_cust_convert,'99999999999999990.99')),0)) netValidCustConvert, to_char(nvl(sum(to_char(pd.net_valid_cust_sum,'99999999999999990.99')),0)) netValidCustSum, to_char(nvl(sum(to_char( pd.net_valid_cust_monthly,'99999999999999990.99')),0)) netValidCustMonthly from kh.tb_snap_user u inner join kh.tb_kh_personal_detail pd on pd.user_id=u.user_id inner join KH.TB_KH_PERSONAL_RESULT PR on PR.P_RESULT_ID=pd.P_RESULT_ID and PR.status = '1' where u.cur_state=0 and pd.IF_REPORT='1' and PR.AUDIT_STS in ('4','5','7') and PR.BRANCH_CODE in ('1010') and PR.RESULT_MONTH = '201012' group by u.dept_id ,null ) order by ordersn,team_name,orderno
相关推荐
**泛微系统SQL语句大全** 在IT行业中,泛微系统是一种广泛应用的企业级协同办公软件,主要用于提升组织的管理效率和工作流程自动化。本资源集合了泛微系统中与SQL Server数据库交互时常用的各种SQL语句,涵盖了组织...
#### 二、SQL语句类型及其在ArcGIS中的运用 ##### 1. 数据操作语言(DML) DML主要用于对数据库中的数据进行增删改查操作,包括以下几种常见语句: - **选择(SELECT)**:用于检索数据库中的数据,是ArcGIS中最常用...
2. SQL语法结构:SQL语句通常由命令关键字组成,包括SELECT、INSERT、UPDATE、DELETE等。这些关键字用于查询、插入、更新和删除数据。例如,SELECT语句用于从数据库中检索数据,INSERT用于添加新记录,UPDATE用于...
SQL语句生成器提供了一个用户友好的界面,允许用户定义表格结构,包括字段名、数据类型、主键等属性。用户只需选择相应的操作,即可自动生成CREATE TABLE或DROP TABLE语句,使得建表和删表变得轻而易举。 再者,SQL...
在数据库管理中,SQL语句的执行效率是关键因素之一,尤其在处理大量数据时。通过对SQL语句的执行计划进行分析,我们可以找到优化查询性能的策略,从而提高数据库系统的整体性能。这篇博客"通过分析SQL语句的执行计划...
在“SQL语句手册.chm”中,我们可以期待找到关于SQL的全面介绍,包括其基本概念、语法以及如何执行各种操作。下面我们将深入探讨SQL的关键知识点。 1. **SQL基础**: SQL的基本组成部分包括数据定义语言(DDL)、...
《SQL语句大全》是一本全面介绍SQL语言的电子书籍,涵盖了从基础到高级的各种SQL操作,旨在帮助读者深入理解和熟练运用SQL进行数据库管理和数据处理。SQL,全称Structured Query Language,即结构化查询语言,是用于...
这本书“SQL语句电子书”显然涵盖了这一主题的广泛内容,旨在帮助读者掌握SQL的基本概念以及高级技巧。 一、SQL基础 1. 数据库概念:SQL语句首先需要理解数据库是什么,包括关系型数据库的基本原理,如表、字段、...
Parameter sniffing 是指 SQL Server 在执行存储过程时,使用参数的统计信息来优化执行计划,但这种优化方式有时可能会导致执行计划的不正确,从而影响存储过程的执行速度。 在了解这个问题之前,我们通常认为存储...
此SQL语句创建一个包含两列的新表:`column1`为整数类型且不允许为空,`column2`为可变长度字符串类型,最大长度为30个字符。 #### 5. 添加主键约束 ```sql altertable<> addprimarykey("column1"); ``` 该语句向...
在SQL编程领域,掌握高效的SQL语句优化技巧和基础知识是至关重要的。以下是对"非常好用的SQL语句优化34条+sql语句基础"这一主题的详细解析: 1. **索引优化**:索引是提高查询速度的关键。创建合适的索引(主键、...
在面试中,掌握SQL语句的能力是衡量候选人技术水平的重要标准。以下将按照标题和描述中的分类,详细介绍SQL语句的相关知识点。 一、基础 SQL的基础包括数据类型(如INT, VARCHAR, DATE等)、DML(Data Manipulation...
本文将详细解析如何通过SQL语句实现这一功能,包括但不限于使用`COUNT()`函数、嵌套查询、类型转换等技术点。 ### SQL语句分析 #### 基础概念 在进行SQL查询时,我们经常需要统计某些数据出现的次数或占比。例如,...
综上所述,Oracle SQL语句性能优化涉及多个方面,包括选择合适的优化器、优化数据访问方式、共享SQL语句、索引策略、查询结构优化以及维护数据库统计信息。通过综合运用这些策略,可以显著提升Oracle数据库的运行...
本资料包包含"SQL Server教学PPT"和"SQL语句大全",旨在提供全面且详细的SQL Server学习资源,帮助初学者快速掌握核心概念与实用技能。 在SQL Server教学PPT中,你将了解到以下关键知识点: 1. **SQL基础**:SQL...
本教程面向初学者,旨在提供全面的SQL基础知识,帮助读者快速掌握SQL语句的基本语法和用途。 一、SQL简介 SQL全称结构化查询语言,它允许用户对数据库进行创建、查询、更新和删除操作。SQL被广泛应用于各种数据库...
通过这些工具,可以详细查看SQL语句如何访问表和索引,以及执行过程中涉及的操作类型。 #### 二、执行计划优化 Oracle数据库的执行计划选择机制有两种:基于成本(Cost-Based Optimizer,CBO)和基于规则(Rule-...
这个压缩包文件"经典SQL语句大全+SQL基础教程.rar"包含了关于SQL的重要学习资源,包括"SQL语句教程.doc"和"经典SQL语句大全.doc"两份文档,旨在帮助初学者掌握SQL的基础知识和常见操作。 1. **SQL基础**: - ...
"数据库图书信息管理数据库SQL语句分享" 本资源摘要信息是关于数据库图书信息管理数据库SQL语句分享的详细知识点总结。 实验目的 1. 了解数据库以及数据表的设计 2. 熟悉 SQL Server 2005 中的数据类型 3. 熟悉...