Link to home
Start Free TrialLog in
Avatar of macomsupport
macomsupport

asked on

SQL 2008 R2 Query count

Hello

I have a the following count Query

Select COUNT (*) as 'Closed' from [macom].[dbo].[dt_HDTicket] Join [macom].[dbo].[dt_HDStatus] on HDTicket_HDStatus_id=HDStatus_ID 
where HDTicket_IsClosed = '1' And HDTicket_Closed >= Dateadd(WW, -1, getdate()) and HDStatus_HDProject_id = '7' and HDStatus_Name <> 'Duplicate' 

Select count (*) as 'Opened' from [macom].[dbo].[dt_HDTicket] Join [macom].[dbo].[dt_HDStatus] on HDTicket_HDStatus_id=HDStatus_ID 
where  HDTicket_Created >= Dateadd(WW, -1, getdate()) and HDStatus_HDProject_id = '7' and HDStatus_Name <> 'Duplicate'

Select count (*) as 'Idle' from [macom].[dbo].[dt_HDTicket] Join [macom].[dbo].[dt_HDStatus] on HDTicket_HDStatus_id=HDStatus_ID 
where HDTicket_IsClosed = '0' And HDTicket_Modified < Dateadd(ww, -1, getdate()) and HDStatus_HDProject_id = '7' and HDStatus_Name <> 'Duplicate'
 
Select count (*) as 'Modified' from [macom].[dbo].[dt_HDTicket] Join [macom].[dbo].[dt_HDStatus] on HDTicket_HDStatus_id=HDStatus_ID 
where HDTicket_IsClosed = '0' And HDTicket_Modified >= Dateadd(ww, -1, getdate()) and HDStatus_HDProject_id = '7' and HDStatus_Name <> 'Duplicate'

Open in new window


Currently this query outputs 4 different tables, I would like to have them displayed in one table like this:
 
Closed, Opened,  Idle, Modified
13,10,15,1

Thanks in advanced.
Avatar of BurundiLapp
BurundiLapp
Flag of United Kingdom of Great Britain and Northern Ireland image

--

Sorry I've misread your question, hang on I'll post code that should do what you are after.
ASKER CERTIFIED SOLUTION
Avatar of BurundiLapp
BurundiLapp
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of macomsupport
macomsupport

ASKER

Perfect. Thanks!