The actual example code below can put the results of a query into a custom table, and you can then query the data from this custom table:
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;