title: SQL passing values from nested queries
body: <p>I have a question regarding the proper way to pass values in nested queries for Oracle SQL.  I have the following code: </p>
  
  <pre><code>SELECT b.business_id
    FROM business b,
         business_category c,
          (SELECT COUNT(*) AS catcount
             FROM business_category b1
            GROUP BY b1.list_of_subcategories)    
  WHERE b.business_category = c.busn_catg_id
    AND catcount = 1;
  </code></pre>
  
  <p>Where the goal is to look into a table called BUSINESS_CATEGORY and count the number of occurrences there are for all the subcategories.  The query is supposed to return the business ID associated with the businesses whose business subcategory only has a count of 1.  Essentially I want to return the businesses who have a unique subcategory(meaning their subcategory isn't used more than once).  </p>
  
  <p>My attempts of doing that can be observed above.  I decided to have a nested query where the inner query returns the count for each of the subcategories and calls its return value Catcount.  I then made sure that the Business_Catg_Id matched up with the Business_Category id's to return the business id's that had the unique categories.  </p>
  
  <p>Thus far its not returning what it should and I don't know why at this point.  I was hoping someone could explain why this is the case.  Here are the tables that correspond with this problem:
  <a href="https://i.stack.imgur.com/Z5Nit.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z5Nit.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/0M0im.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0M0im.png" alt="enter image description here"></a></p>