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;