当前位置:网站首页>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
边栏推荐
- Introduction to tensorrt
- [leetcode sword finger offer 28. Symmetric binary tree (simple)]
- Automatic heap dump using MBean
- Two Stage Detection
- 2.整理华子面经--2
- Realrange, reduce, repeat and einops in einops package layers. Rearrange and reduce in torch. Processing methods of high-dimensional data
- 1. Finishing huazi Mianjing -- 1
- IOT 设计与开发
- Tencent cloud has two sides in an hour, which is almost as terrible as one side..
- Send email to laravel
猜你喜欢
thinkphp5+数据大屏展示效果
Keywords static, extern + global and local variables
Display, move, rotate
What about laptop Caton? Teach you to reinstall the system with one click to "revive" the computer
[leetcode refers to the maximum profit of offer 63. Stock (medium)]
C#,打印漂亮的贝尔三角形(Bell Triangle)的源程序
Pycharm download and installation
Common problems in deploying projects with laravel and composer for PHP
go defer
随机推荐
unity 功能扩展
Ubutnu20 installer centernet
On the three paradigms of database design
YOLOv5 Unable to find a valid cuDNN algorithm to run convolution
2.整理华子面经--2
Addition, deletion, modification and query of MySQL advanced table
How to make Jenkins job run automatically after startup
管道和xargs
The more you use the computer, the slower it will be? Recovery method of file accidental deletion
Assertionerror: invalid device ID and runtimeerror: CUDA error: invalid device ordinal
[※ leetcode refers to offer 46. Translate numbers into strings (medium)]
Recommended usage scenarios and production tools for common 60 types of charts
Thinking after learning to type
C, print the source program of beautiful bell triangle
Plato Farm元宇宙IEO上线四大,链上交易颇高
Addition, deletion, modification and query of advanced MySQL data (DML)
DW basic tutorial (I)
Lunch on the 23rd day at home
IOT 设计与开发
thinkphp5+数据大屏展示效果