Oracle将查询的结果放入一张自定义表中并再查询数据

前端技术 2023/09/06 Oracle

如下的实际例子代码可以将查询的结果放入到一张自定义表中,同时可以再从这个自定义的表中查询数据:

with AA as
(SELECT TICKETNUMBER, TICKETTYPE, VERSIONNUMBER, STAGENAME, DTANALYZED,
GISPROCESSID, PROCESSSTATUS, DTRECEIVED, USERID, USERNAME, FIRSTNAME,
LASTNAME, NUMBEROFDAYS
FROM REPORT_PERFORMANCEOFANALYZER
WHERE (DTANALYZED IS NULL)
UNION ALL
SELECT TICKETNUMBER, TICKETTYPE, VERSIONNUMBER, STAGENAME, DTANALYZED,
GISPROCESSID, PROCESSSTATUS, DTRECEIVED, USERID, USERNAME, FIRSTNAME,
LASTNAME, NUMBEROFDAYS
FROM 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) COUNTTICKETS
FROM AA
ORDER BY USERNAME;

本文地址:https://www.stayed.cn/item/17177

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。