欢迎来到福编程网,本站提供各种互联网专业知识!
您的位置:网站首页 > 数据库 > Oracle

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

发布时间:2014-08-11 作者:投稿whsnow 来源:转载
可以将查询的结果放入到一张自定义表中,同时可以再从这个自定义的表中查询数据,详细的sql如下,感兴趣的朋友不要错过

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

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;

相关推荐