April 10, 2013 at 10:31 am
Hello Everyone.
I have 2 separate queries that I would like to join together, but have been unable to.
I would like to run a single query that would return
3 columns 'Name0', 'Agenttime' and 'LastBootUpTime0'
Does anyone know how I can accomplish this?
Thanks!
------------------------------------------------------------------
select
Name0,
Agenttime
from
v_AgentDiscoveries AGD,
dbo.v_GS_COMPUTER_SYSTEM CS
Where
CS.ResourceID = AGD.ResourceID
and AGD.AgentName = 'Heartbeat Discovery'
order by
Name0
--------------------------------------------------------------------
SELECT distinct sys.Name0, os.LastBootUpTime0 FROM v_R_System sys
join v_GS_OPERATING_SYSTEM os on sys.ResourceID=os.ResourceID join v_FullCollectionMembership fcm on fcm.ResourceID=os.ResourceID
April 10, 2013 at 10:42 am
Have you tried union all? The columns just need to be the same, so you will need to add a dummy column of the same type to your second query for the missing one.
April 10, 2013 at 12:07 pm
Here's one approach that might work.
With cte_agenttime
As
(
Select
Name0,
Agenttime
From
v_AgentDiscoveries AGD
Inner join dbo.v_GS_COMPUTER_SYSTEM CS
On CS.ResourceID = AGD.ResourceID
Where
AGD.AgentName = 'Heartbeat Discovery'
),
cte_boottime
As
(
Select distinct
sys.Name0,
os.LastBootUpTime0
From
v_R_System sys
Inner join v_GS_OPERATING_SYSTEM os
On sys.ResourceID= os.ResourceID
Inner join v_FullCollectionMembership fcm
On fcm.ResourceID=os.ResourceID
)
Select
Name0,
Agenttime,
LastBootUpTime0
From
cte_agenttime ca
Inner join cte_boottime cb
On ca.Name0 = cb.Name0
;
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply