Oracle puts the query results into a custom table and then queries data.

Source: Internet
Author: User

Oracle puts the query results into a custom table and then queries data.

The actual example code below can put the query results into a custom table and query data from this custom table:

with AA as(SELECT TICKETNUMBER, TICKETTYPE, VERSIONNUMBER, STAGENAME, DTANALYZED,GISPROCESSID, PROCESSSTATUS, DTRECEIVED, USERID, USERNAME, FIRSTNAME,LASTNAME, NUMBEROFDAYSFROM REPORT_PERFORMANCEOFANALYZERWHERE (DTANALYZED IS NULL)UNION ALLSELECT TICKETNUMBER, TICKETTYPE, VERSIONNUMBER, STAGENAME, DTANALYZED,GISPROCESSID, PROCESSSTATUS, DTRECEIVED, USERID, USERNAME, FIRSTNAME,LASTNAME, NUMBEROFDAYSFROM REPORT_PERFORMANCEOFANALYZER REPORT_PERFORMANCEOFANALYZER_1)SELECT TICKETNUMBER, TICKETTYPE, VERSIONNUMBER, STAGENAME, DTANALYZED,GISPROCESSID, PROCESSSTATUS, DTRECEIVED, USERID, USERNAME, FIRSTNAME,LASTNAME, NUMBEROFDAYS,(SELECT COUNT(GISPROCESSID) AS COUNTTICKETS FROM AA) COUNTTICKETSFROM AAORDER BY USERNAME;


How can I insert the queried data into another table in oracle?

Insert into t_tab
Select * from s_tab where Condition

The view can be seen as the deformation of one or more tables in the mirror,
As long as the table changes, the view content also changes.

How to display multiple query results in one table in oracle

-- You can use external join in sql99 syntax, as shown below:
SELECT
Case when table 1. Name IS NOT NULL
THEN table 1. Name
Else case when table 2. Name IS NOT NULL
THEN Table 2. Name
Else case when table 3. Name IS NOT NULL
THEN Table 3. Name ELSE 'unknown'
END
END
End as name
, Table 1. Number of people, Table 2. Number of people, Table 3. Number of people
FROM table 1 FULL OUTER JOIN
T2 ON table 1. Name = TABLE 2. Name
FULL OUTER JOIN
T3 ON table 1. Name = TABLE 3. Name
-- If there are more than n tables in this method, the name will be tedious to write, but the idea should be fine.
-- If it looks troublesome, you can change the statement between select and from to *. I believe you can understand the result.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.