title: FROM Clause Subquery Add a Column from Another Table
body: <p>I am having trouble wrapping my head around a subquery in the FROM clause. I have a subquery that I want to add to the FROM clause. I only added the nconst column, then JOIN it to the name_basics table with the column nconst and it does everything but what it should output. Why would that be? It makes no sense that the code should mess up, all I am doing is adding another column, not manipulating the code (as far as I know). </p>
  
  <p>Also, it has to be in the FROM clause for the assignment. I am just looking for clarification. I know how the FROM clause works when linking direct keys for the output column. For this, I don't want to show the nconst value in the output and that is where I am lost. </p>
  
  <p>The output should be the name of everyone in that profession. The NP subquery originally doesn't have nconst values in it.</p>
  
  <p>Here is my code</p>
  
  <pre><code>SELECT  primaryName, profession
     FROM (
          SELECT      profession, COUNT(*) AS TOTAL, nconst
          FROM        name_profession
          GROUP BY    profession, nconst
          HAVING      COUNT(*) &lt; 1000             
      ) AS NP
  JOIN    
      (
          SELECT      primaryName, nconst
          FROM        name_basics
      ) AS NB
  ON      NP.nconst = NB.nconst
  ORDER BY primaryName;
  </code></pre>