title: SQL Join two query
body: <p><a href="https://i.stack.imgur.com/mxnlW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxnlW.png" alt="enter image description here"></a><img src="https://i.stack.imgur.com/ZMZsD.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/yMcmL.png" alt="enter image description here"></p>
  
  <p>I need some help combining these two queries so I can get this in one single view.</p>
  
  <p>Query 1</p>
  
  <pre><code>select t.*, n.caption, n.description
  from (
      select NodeID, 
                count(distinct cpuindex) as number_of_cpu, 
                  case 
                             When count(distinct cpuindex) &lt; 8 THEN 1
                             Else count(distinct cpuindex)/8 
                             End AS number_of_cores
      from CPUMultiLoad_Detail (nolock) where nodeid in (select nodeid from nodesdata)
         group by NodeID
     ) as t
  inner join NodesData as n (nolock) on n.nodeid = t.nodeid
  where n.description NOT Like '%Windows%'
  order by n.description
  </code></pre>
  
  <p>Query 2</p>
  
  <pre><code>SELECT D.Environment, B.Name, C.Caption, A.ComponentStatisticData, A.ErrorMessage
  FROM [APM_CurrentStatistics] A, APM_Application B, NodesData C
  join NodesCustomProperties D on D.NodeID= C.NodeID
  WHERE 
  A.ApplicationID=B.ID AND
  A.NodeID=C.NodeID AND 
  B.Name IN ('Oracle Database Licensing') 
  </code></pre>
  
  <p>I want to join first query and second query so I have CPU Information and Licensing Information in same table. How do I join both query? We can use common key Nodes.NodeID to join and not sure how. Any help will be greatly appreciated.</p>