Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Incorporate two queries from the same table.

$
0
0

Hello,

I would like to extend the parameters available by adding a few more columns into a query.

I've tried to union join them but they are so different that it may not be possible to have a count query filtered by further columns but I would like to ask the question, and very much appreciate a push in the right direction to achieving this.

The queries are below.

Select i.OrganizationUnitID, i.OwnerTeam 
 from Incident i
	where i.OrganizationUnitID  in (@OrgUnit)
	and i.OwnerTeam in (@Team)

To a count query:

declare @st_date datetime;
declare @en_date datetime;
declare @days int;

set @en_date = (@en_datein);
set @st_date = (@st_datein);

select 
	 iast.incidentcount
	,icst.incidentclosedcount
	,@st_date startdate
	,@en_date enddate
from
(select 
	COUNT(*) as incidentcount
	from incident i
	where i.CreatedDateTime >= @st_date
	and i.CreatedDateTime <= @en_date
)as iast
,(select 
	COUNT(*) as incidentclosedcount
	from incident i
	where i.ClosedDateTime >= @st_date
	and i.ClosedDateTime <= @en_date
	and i.Status = 'Closed'
)as icst

If this isn't easy, I would be interested in hearing what the professional method would be.

Thank you so much.


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>