当前位置:网站首页>Mixed use of Oracle column row conversion and comma truncated string
Mixed use of Oracle column row conversion and comma truncated string
2022-04-23 21:25:00 【Plant a sweet smell】
oracle The mixed use of column to row conversion and string truncation with commas
lately , When writing a stored procedure to return a value to the front end , The mixed use of row to column and intercepted string is used
Data to be converted

Data you want to achieve

Realization SQL
```sql
select OLD_REEL,OLD_QTY,substr(REEL,0,decode(instr(REEL, ','),0,length(REEL),instr(REEL, ',') - 1)) as newreel1,
substr(qty1,0,decode(instr(qty1, ','),0,length(qty1),instr(qty1, ',') - 1)) as reelqty1,
substr(REEL,decode(instr(REEL, ','),0,length(REEL),instr(REEL, ',') + 1)) as newreel2,
substr(qty1,decode(instr(qty1, ','),0,length(qty1),instr(qty1, ',') + 1)) as reelqty2 from (select OLD_REEL,
OLD_QTY,
listagg(NEW_REEL,',') within GROUP (order by NEW_REEL) over (partition by OLD_REEL) REEL,
listagg(qty,',') within GROUP (order by qty) over (partition by OLD_QTY) qty1
from WMS_REEL_IQC where OLD_REEL='551R17083000056') t where rownum=1;
##### explain :1.
`select OLD_REEL,
OLD_QTY,
listagg(NEW_REEL,',') within GROUP (order by NEW_REEL) over (partition by OLD_REEL) REEL,
listagg(qty,',') within GROUP (order by qty) over (partition by OLD_QTY) qty1
from WMS_REEL_IQC where OLD_REEL='551R17083000056'` this SQL Realize row to column conversion , The function used listagg
2.`select OLD_REEL,OLD_QTY,substr(REEL,0,decode(instr(REEL, ','),0,length(REEL),instr(REEL, ',') - 1)) as newreel1,
substr(qty1,0,decode(instr(qty1, ','),0,length(qty1),instr(qty1, ',') - 1)) as reelqty1,
substr(REEL,decode(instr(REEL, ','),0,length(REEL),instr(REEL, ',') + 1)) as newreel2,
substr(qty1,decode(instr(qty1, ','),0,length(qty1),instr(qty1, ',') + 1)) as reelqty2` this SQL Implementation with comma ‘,’ Intercepting string , If you want to intercept other strings , Replace the comma with the character you want .
版权声明
本文为[Plant a sweet smell]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200619557390.html
边栏推荐
- flomo软件推荐
- Sklearn function: Train_ Test_ Split (split training set and test set)
- 【SDU Chart Team - Core】SVG属性类设计之枚举
- Pytorch selects the first k maximum (minimum) values and their indexes in the data
- Send email to laravel
- 1. Finishing huazi Mianjing -- 1
- Thinkphp5 + data large screen display effect
- Write table of MySQL Foundation (create table)
- [※ leetcode refers to offer 46. Translate numbers into strings (medium)]
- Addition, deletion, modification and query of advanced MySQL data (DML)
猜你喜欢
![[※ leetcode refers to offer 46. Translate numbers into strings (medium)]](/img/72/fbdc5d14dada16cd211c99cd8f9d31.png)
[※ leetcode refers to offer 46. Translate numbers into strings (medium)]

Lunch on the 23rd day at home

Minecraft 1.12.2模组开发(四十三) 自定义盾牌(Shield)
![[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]](/img/ab/698810f6fe169adffc3bec5e0dc13f.png)
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]

Recommended usage scenarios and production tools for common 60 types of charts

Arm architecture assembly instructions, registers and some problems

Express③(使用Express编写接口、跨域有关问题)

Based on jsplumb JS to achieve multi list one to many connection effect

Keywords static, extern + global and local variables

C#,打印漂亮的贝尔三角形(Bell Triangle)的源程序
随机推荐
Detectron2 usage model
How to learn software testing? Self study or training? After reading this article, you will understand
Addition, deletion, modification and query of MySQL advanced table
Crisis is opportunity. Why will the efficiency of telecommuting improve?
[leetcode refers to offer 18. Delete the node of the linked list (simple)]
airbase 初步分析
[leetcode sword finger offer 10 - II. Frog jumping steps (simple)]
[leetcode refers to the maximum profit of offer 63. Stock (medium)]
Thinkphp5 + data large screen display effect
Another data analysis artifact: Polaris is really powerful
Solve importerror: cannot import name 'imread' from 'SciPy misc‘
3-5 obtaining cookies through XSS and the use of XSS background management system
DW basic tutorial (I)
[leetcode refers to offer 47. Maximum value of gift (medium)]
Ubutnu20 installer centernet
[leetcode refers to the substructure of offer 26. Tree (medium)]
1. Finishing huazi Mianjing -- 1
Deep understanding of modern mobile GPU (continuously updating)
Based on jsplumb JS to achieve multi list one to many connection effect