当前位置:网站首页>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
边栏推荐
- Arm architecture assembly instructions, registers and some problems
- Google tries to use rust in Chrome
- FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ‘:app:stripDe
- Chrome 94 introduces the controversial idle detection API, which apple and Mozilla oppose
- Valueerror: invalid literal for int() with base 10 conversion error related to data type
- Detectron2 using custom datasets
- Pyuninstaller package exe cannot find the source code when running, function error oserror: could not get source code
- Two Stage Detection
- Zhongchuang storage | how to choose a useful distributed storage cloud disk
- Crisis is opportunity. Why will the efficiency of telecommuting improve?
猜你喜欢

Is rust more suitable for less experienced programmers?

The more you use the computer, the slower it will be? Recovery method of file accidental deletion
![[leetcode refers to offer 47. Maximum value of gift (medium)]](/img/b4/34b3c74516e3b1ba93b7d84916dadc.png)
[leetcode refers to offer 47. Maximum value of gift (medium)]

flomo软件推荐
![[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]](/img/ab/698810f6fe169adffc3bec5e0dc13f.png)
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
![[leetcode refers to the maximum profit of offer 63. Stock (medium)]](/img/37/478b53696f9327b7d435cdd887dd57.png)
[leetcode refers to the maximum profit of offer 63. Stock (medium)]

Display, move, rotate

Google 尝试在 Chrome 中使用 Rust
![[leetcode refers to offer 25. Merge two sorted linked lists (simple)]](/img/7b/b31b1a128e8b48c56493131e0f26c5.png)
[leetcode refers to offer 25. Merge two sorted linked lists (simple)]

Gsi-ecm digital platform for engineering construction management
随机推荐
Pytorch selects the first k maximum (minimum) values and their indexes in the data
Alibaba cloud responded to the disclosure of user registration information
Pytorch preserves different forms of pre training models
IOT design and development
Automatic heap dump using MBean
ros功能包内自定义消息引用失败
How Axure installs a catalog
Crisis is opportunity. Why will the efficiency of telecommuting improve?
Common commands of MySQL in Linux
Graph traversal - BFS, DFS
【SDU Chart Team - Core】SVG属性类设计之枚举
Fastdfs mind map
Detectron2 using custom datasets
Pikachuxss how to get cookie shooting range, always fail to return to the home page
Flomo software recommendation
Minecraft 1.12.2模组开发(四十三) 自定义盾牌(Shield)
Two Stage Detection
Preliminary analysis of Airbase
Subcontracting of wechat applet based on uni app
UKFslam