Mysql行列转换sql语句
2023-09-14 09:02:02 时间
@Select("<script>" +
"select d.id driverId,d.name driverName,d.Org_Id orgId,d.cooperation_company_id cooperationCompanyId,\n" +
"sum(CASE r.record_type WHEN 1 THEN r.record_money ELSE 0 END ) orderMoney,\n" +
"sum(CASE r.record_type WHEN 2 THEN r.record_money ELSE 0 END ) withdrawalsMoney,\n" +
"sum(CASE r.record_type WHEN 3 THEN r.record_money ELSE 0 END ) rewardMoney,\n" +
"sum(CASE r.record_type WHEN 4 THEN r.record_money ELSE 0 END ) punishmentMoney,\n" +
"sum(CASE r.record_type WHEN 5 THEN r.record_money ELSE 0 END ) shareMoney\n" +
"from basic_driver d, driver_account_record r, (SELECT getChildrenOrg(#{orgId}) orgs) t\n" +
"where FIND_IN_SET(d.org_Id, orgs)\n" +
"and d.id=r.driver_id\n" +
"<if test=\"driverName!=null and driverName!=''\">and d.name=#{driverName}</if>\n" +
"<if test=\"startDate!=null and startDate!=''\"> and r.record_time <![CDATA[ >= ]]> #{startDate} </if>\n" +
"<if test=\"endDate!=null and endDate!=''\"> and r.record_time <![CDATA[ < ]]> date_add(#{endDate}, interval 1 day) </if>\n" +
"<if test=\"cooperationCompanyId!=0 and cooperationCompanyId!=-1\">and d.cooperation_company_id=#{cooperationCompanyId}</if>\n" +
"group by d.id" +
"</script>")
List<AccountTotal> accountMoney(AccountTotal accountTotal);
相关文章
- php 版本号 整数化 mysql存储入库 比较大小【版本处理类,提供版本与数字互相转换】
- mysql行转列转换
- MYSQL日期 字符串 时间戳互转
- mysql调整时区
- MySQL数据库如何与EXCEL的XLS格式相互转换
- MYSQL的硬盘IO过高引起的CPU过高判断
- 【原创】基于 MySQL Connector/C 实现客户端程序之 API 总结
- mysql查询之分数排名
- MySQL · 参数优化 ·RDS MySQL参数调优最佳实践
- MySQL运维---慢日志与备份
- MySQL逻辑架构
- 【转】Mysql行转换为列
- piap.excel 微软 时间戳转换mssql sql server文件时间戳转换unix 导入mysql
- 【华为云技术分享】华为云MySQL新增MDL锁视图特性,快速定位元数据锁问题
- mysql死锁问题
- JAVA连接ACCESS、MYSQL、SQLSEVER、ORACLE数据库
- Postgresql分页Limit,如何将Mysql的分页转换为Postgresql的分页
- mysql时间戳转换
- MySQL之自带四库之performance_schema库
- MySQL题集