Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Type Query

Status
Not open for further replies.

hempjammer

Technical User
Nov 9, 2001
6
US
I am wanting to generate a report using TSql and am having problems understanding how to join my queries into a single query.
Query #1:
SELECT distinct(Incident."Group Name"),Count(*) "Backlog"
FROM "_SMDBA_".Incident Incident
WHERE
((Incident."Group Name" LIKE 'IT-%') OR (Incident."Group Name" LIKE 'ITI-%')
OR (Incident."Group Name" LIKE 'ITP-%') OR (Incident."Group Name" LIKE 'ITS-%')
OR (Incident."Group Name" IN ('SYSTEM ADMINS', 'IT-SENIOR STAFF','IT-EHO'))) AND
Incident."State:"='O' and
Incident."Close Date" is null
group by Incident."Group Name"
order by 1

Query #2

SELECT Count(*) "Total Backlog"
FROM "_SMDBA_".Incident Incident
WHERE
((Incident."Group Name" LIKE 'IT-%') OR (Incident."Group Name" LIKE 'ITI-%')
OR (Incident."Group Name" LIKE 'ITP-%') OR (Incident."Group Name" LIKE 'ITS-%')
OR (Incident."Group Name" IN ('SYSTEM ADMINS', 'IT-SENIOR STAFF','IT-EHO'))) AND
Incident."State:"='O' and
Incident."Close Date" is null

The results that I would like are:
Group Name Backlog
------------------------------ -----------
IT-APPSUPP GLOBAL 1
IT-EBS 261

Total Backlog
-------------
262

Many thanks in advance

 
Since your results show two recordsets, I would keep this as two queries. YOu can put both into one stored procedure.

Or if you can accept one recordset witha total line try the WITH ROLLUP command at the end of the first query.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top