title: SQL Subqueries, map one field to another, and make a separate lookup/count against another table
body: <p><a href="https://i.stack.imgur.com/ffgaM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ffgaM.png" alt="enter image description here" /></a></p>
  <p>I have a spreadsheet with about ~1000 rows, and 2 columns.
  I've been given Postgres DB access and have been tasked with making some lookups. I think manually this would take forever, I am hopeful that there is a way easier way to do this w/ SQL queries</p>
  <ol>
  <li><p>I need to get an associated <code>UserID</code> from each row, by making a lookup in the <code>users</code> table, which has a <code>PhoneNumber</code> column</p>
  </li>
  <li><p>There is another table <code>user_orders</code> where <code>UserId</code> maps to an <code>Order</code>. I need to count how many <code>Orders</code> each user has made</p>
  </li>
  </ol>
  <p>So what I'm looking for is to convert Phone Numbers -&gt; UserID -&gt; Order Count.</p>
  <p>I am using Postico to construct queries against my database. I can figure out a way to export the phone numbers into a comma separated list, but I'm completely lost from that step</p>