1. Business needs
In the development process of the oracle project, after using sql to write the corresponding analysis report content, some lines involved in the sql analysis report are lost, resulting in the dislocation of the statistical line data that is fixedly marked with eye-catching colors when the report is classified and counted; Therefore, it is necessary to repair the complete line classification of the analysis report.
2. Business analysis
After writing the corresponding analysis report content in sql, due to the missing data of some lines, the report shows that the lines with missing data are not displayed; now it is necessary to display the lines with missing data. The easiest way is to right-join the existing sql statement to a fixed-line temporary table (but use the with as in oracle to create a fixed-line temporary table).
3. Implementation method
3.1, With as usage
SQL | Join (Inner, Left, Right and Full Joins) - GeeksforGeekshttps://www.geeksforgeeks.org/sql-join-set-1-inner-left-right-and-full-joins/ SQL JOIN 连接_w3cschoolhttps://www.w3cschool.cn/sql/2nmo1oyt.html
3.2, with as to create a temporary table
① Create a temporary table syntax
with 临时表名称 as(
SELECT 值1 列名1,值2 列名2 from dual union all
SELECT 值1 列名1,值2 列名2 from dual union all
SELECT 值1 列名1,值2 列名2 from dual
)
SELECT * from 临时表名称
② Create a temporary table example
with TEMPTABLE as(
SELECT 1 LINE, '一线' NOTES from dual union all
SELECT 2 LINE, '二线' NOTES from dual union all
SELECT 3 LINE, '三线' NOTES from dual
)
SELECT * from TEMPTABLE
Example execution results are as follows: