title: Performing a JOIN with the results of a WITH clause
body: <p>I have one query that uses one join already, call it query1. I would like to join query1 to the results of a WITH clause. I don't know how to merge the two data sets. </p>
  
  <p>Query 1: </p>
  
  <pre><code>SELECT 
      p.NetObjectID 
      , n.Caption, n.ObjectSubType
  FROM Pollers p
  LEFT JOIN NodesData n ON n.NodeID = p.NetObjectID
  </code></pre>
  
  <p>The next query is a WITH clause. I don't know how to obtain the results without a WITH because I need to do what is outlined in <a href="https://stackoverflow.com/questions/1313120/retrieving-the-last-record-in-each-group-mysql">this post</a>. </p>
  
  <p>Query 2:</p>
  
  <pre><code>WITH ranked_DateStamp AS 
  (
      SELECT c.NodeID, c.DateTime
          , ROW_NUMBER() OVER (PARTITION BY NodeID ORDER BY DateTime DESC) AS rn
      FROM CPULoad AS c
  )
  SELECT *
  FROM ranked_DateStamp
  WHERE rn = 1;
  </code></pre>
  
  <p>I thought I could just JOIN ranked_DateStamp ON ranked_DateStamp.NodeID = p.NodeID but it won't allow it. </p>