- 浏览: 48089 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
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
相关推荐
10、说明:几个简单的基本的sql语句 选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1...
主要为大家按日,星期,月,季度,年统计销售额的sql语句,需要的朋友可以参考下
显示第一个语句中不在第二个语句中的项 [SQL 语句 1] MINUS [SQL 语句 2] (21) Concatenate................................... ............... ...............................12 结果相加(串联) MySQL/Oracle...
第一章 SQL Server基础 ? ? 1、SQL 2008视频教程—SQL数据库连接 ? 2、SQL 2008视频教程-系统数据库 ? 3、SQL 2008视频教程-数据库创建 ? 4、SQL 2008视频教程-数据库创建2 ... 17、利用T-SQL语句修改视图
下面给出上图的例子的sql语句写法:(注:此处是按“日期”字段统计) 代码如下: select 日期,自选字段1,自选字段2,sum(类型1) 类型1,sum(类型2) 类型2,sum(类型3) 类型3,sum(类型4) 类型4,sum(类型5) 类型5,sum(类型6...
10、说明:几个简单的基本的sql语句 选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1...
SQL基本语句使用示例 目录 --数据操作 2 --数据定义 2 --数据控制 2 --事务控制 2 --程序化SQL 2 ---局部变量 3 --IF ELSE 3 --CASE 3 --WHILE CONTINUE BREAK 3 --WAITFOR 4 ***SELECT*** 4 ***insert*** 5 ***...
5. Executor执行器要处理的SQL信息是封装到一个底层对象MappedStatement中 该对象包括SQL语句 输入参数映射信息 输出结果映射信息 其中输入参数和输出结果的映射类型包括HashMap集合对象 POJO对象类型
软件介绍 1、SELECT 查询...插入时须考虑清楚字段类型避免插入后出现缺值,乱码现象 4、Update 更新语句 UPDATE 表名 SET 字段 = 值 WHERE 条件 limit 5、Delete 删除语句 DELETE FROM 表名 WHERE 条件 limit
经典SQL语句大全 一、基础 1、说明:创建数据库 CREATE DATABASE database-name 2、说明:删除数据库 drop database dbname 3、说明:备份sql server --- 创建 备份数据的 device USE master EXEC sp_addumpdevice ...
包含的字段为: v.id 任务编号, d.`name` 部门名称, CONCAT(v.assignedTo,'(',u.realname,')')登记人, ... v.`type` 任务类型, v.assignedDate 预计开始时间, v.begintime 任务开始时间, v.endtime 任务完成时间
读者不仅可以掌握Oracle常用工具Oracle Universal Installer、Net Comfiguration Assistant、SQL Developer、SQL*Plus的作用及使用方法,而且可以掌握SQL语句和PL/SQL的各种基础知识和高级特征(记录类型、集合类型...
读者不仅可以掌握oracle常用工具oracle universal installer、net comfiguration assistant、sql developer、sql*plus的作用及使用方法,而且可以掌握sql语句和pl/sql的各种基础知识和高级特征(记录类型、集合类型...
my2sqlgo版MySQL binlog解析...分析主库执行SQL语句除了支持常规数据类型,对大部分工具不支持的数据类型做了支持,比如json、blob、text、emoji等数据类型sql生成产品性能对比binlog2sql当前是业界使用最广泛MySQL回
Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程表 SC(S#,C#,score) 成绩表 Teacher(T#,Tname) 教师表 问题: 1、查询“001”课程比“002”课程成绩高的所有学生的学号; ...
读者不仅可以掌握oracle常用工具oracle universal installer、net comfiguration assistant、sql developer、sql*plus的作用及使用方法,而且可以掌握sql语句和pl/sql的各种基础知识和高级特征(记录类型、集合类型...
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql 2.导出一个表 mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名 mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql 3.导出一个数据库结构 mysqldump ...
--查看进程所执行的SQL语句 if (select COUNT(*) from master.dbo.sysprocesses) > 500 begin select text,CROSS APPLY master.sys.dm_exec_sql_text(a.sql_handle) from master.sys.sysprocesses a end ...
10、说明:几个简单的基本的sql语句 选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1...