当前位置:网站首页>Correction of date conversion format error after Oracle adds a row total
Correction of date conversion format error after Oracle adds a row total
2022-04-23 21:25:00 【Plant a sweet smell】
1. Problem description : In the total of the company's increase statement , There are two ways to increase the total . One way is to add a column after the queried data ( Last blog has written ); Another way is to add a row total after the queried data . But there will be date conversion errors in the data you query , This is because Oracle Of decode The return value of the built-in function is not of date type . At this time, you need to convert the character format .
1. Wrong date SQL Sum graph
SELECT DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,' total ', Finished product item no ) Finished product item no ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', Finished product specification ) Finished product specification ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', The repair order ) The repair order ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', Stock in quantity ) Stock in quantity ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', Case number ) Case number ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', Operator ) Operator ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING( Storage time ),8,'-', Storage time ,) Storage time ,
SUM( Stock in quantity ) FROM
(SELECT B.PART_NO AS Finished product item no ,B.SPEC1 AS Finished product specification ,A.WORK_ORDER AS The repair order ,A.QTY AS Stock in quantity ,A.BILL_NO AS Stock in No ,A.CONTAINER_NO AS Case number ,C.EMP_NAME AS Operator ,A.UPDATE_TIME AS Storage time
FROM SAJET.WMS_PRODUCTS_IN A LEFT JOIN SAJET.SYS_PART B ON A.PART_ID=B.PART_ID
LEFT JOIN SAJET.SYS_EMP C ON A.UPDATE_USERID=C.EMP_ID
WHERE 1=1
AND A.BILL_NO IN(SELECT LIST_NO FROM SAJET.TBLK3_BILL_RECORD WHERE ORDER_TYPE IN('1','2') AND ISOK='1')
AND A.WORK_ORDER='WORK014084'
--[AND B.PART_NO=:PARAM1]
--[AND A.WORK_ORDER=:PARAM2]
--[AND A.BILL_NO=:PARAM3]
--[AND A.UPDATE_TIME BETWEEN:PARAM4]
ORDER BY A.UPDATE_TIME DESC) GROUP BY ROLLUP(( Finished product item no , Finished product specification , The repair order , Stock in quantity , Stock in No , Case number , Operator , Storage time ))
chart :
2. Correct SQL Sum graph
SELECT DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,' total ', Finished product item no ) Finished product item no ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-', Finished product specification ) Finished product specification ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-', The repair order ) The repair order ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-', Stock in quantity ) Stock in quantity ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-', Case number ) Case number ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-', Operator ) Operator ,
DECODE (GROUPING( Finished product item no )+GROUPING( Finished product specification )+GROUPING( The repair order )+GROUPING( Stock in quantity )+GROUPING( Stock in No )+GROUPING( Case number )+GROUPING( Operator )+GROUPING(TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')),8,'-',TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')) Storage time ,
SUM( Stock in quantity ) FROM
(SELECT B.PART_NO AS Finished product item no ,B.SPEC1 AS Finished product specification ,A.WORK_ORDER AS The repair order ,A.QTY AS Stock in quantity ,A.BILL_NO AS Stock in No ,A.CONTAINER_NO AS Case number ,C.EMP_NAME AS Operator ,A.UPDATE_TIME AS Storage time
FROM SAJET.WMS_PRODUCTS_IN A LEFT JOIN SAJET.SYS_PART B ON A.PART_ID=B.PART_ID
LEFT JOIN SAJET.SYS_EMP C ON A.UPDATE_USERID=C.EMP_ID
WHERE 1=1
AND A.BILL_NO IN(SELECT LIST_NO FROM SAJET.TBLK3_BILL_RECORD WHERE ORDER_TYPE IN('1','2') AND ISOK='1')
AND A.WORK_ORDER='WORK014084'
--[AND B.PART_NO=:PARAM1]
--[AND A.WORK_ORDER=:PARAM2]
--[AND A.BILL_NO=:PARAM3]
--[AND A.UPDATE_TIME BETWEEN:PARAM4]
ORDER BY A.UPDATE_TIME DESC) GROUP BY ROLLUP(( Finished product item no , Finished product specification , The repair order , Stock in quantity , Stock in No , Case number , Operator ,TO_CHAR( Storage time ,'YYYY-MM-DD HH24:MI:SS')))
chart :
版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619557615.html
边栏推荐
- 电脑越用越慢怎么办?文件误删除恢复方法
- Solve importerror: cannot import name 'imread' from 'SciPy misc‘
- [SDU chart team - core] enumeration of SVG attribute class design
- Express ③ (use express to write interface and cross domain related issues)
- 1. Finishing huazi Mianjing -- 1
- C knowledge
- Detailed explanation of basic assembly instructions of x86 architecture
- 韩国或将禁止苹果和谷歌向开发者抽佣 创全球首例
- Addition, deletion, modification and query of advanced MySQL data (DML)
- Pycharm Chinese plug-in
猜你喜欢

Use 3080ti to run tensorflow GPU = 1 X version of the source code

Arm architecture assembly instructions, registers and some problems

Pipes and xargs
![[leetcode refers to offer 47. Maximum value of gift (medium)]](/img/b4/34b3c74516e3b1ba93b7d84916dadc.png)
[leetcode refers to offer 47. Maximum value of gift (medium)]

ROS学习笔记-----ROS的使用教程

笔记本电脑卡顿怎么办?教你一键重装系统让电脑“复活”

阿里又一个“逆天”容器框架!这本Kubernetes进阶手册简直太全了

Pycharm download and installation

Thinkphp5 + data large screen display effect

Two Stage Detection
随机推荐
Explore ASP Net core read request The correct way of body
Tensorflow1. X and 2 How does x read those parameters saved in CKPT
Common problems in deploying projects with laravel and composer for PHP
Detectron2 usage model
1. Finishing huazi Mianjing -- 1
阿里又一个“逆天”容器框架!这本Kubernetes进阶手册简直太全了
What if Jenkins forgot his password
Thread safe sigleton (singleton mode)
Alibaba cloud responded to the disclosure of user registration information
Tensorflow realizes gradient accumulation, and then returns
Addition, deletion, modification and query of MySQL advanced table
Another data analysis artifact: Polaris is really powerful
Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
Express ③ (use express to write interface and cross domain related issues)
Fastdfs mind map
1.整理华子面经--1
一文解决浏览器跨域问题
The more you use the computer, the slower it will be? Recovery method of file accidental deletion
Xiaomi mobile phone has abandoned the "Mi" brand all over the world and switched to the full name brand of "Xiaomi"
Some grounded words