title: SQL - I have a 'People' table and an 'Account' table. How do I list all of the people in rows, and have a balance column for each account type?
body: <p>I was having a hard time figuring out how to title this question, so my apologies in advance.</p>
  
  <p>Here is my my situation:</p>
  
  <p>I have one table that has just people in it. I have another table that has all the accounts, with a personID, accountType, and balance column. A person can have multiple accounts, there are different account types, and not everyone has all of the different account types. </p>
  
  <p>How can I write a query where I list one person per row, and have a column for the balance of each "account type"?</p>
  
  <p>Ideally, my query would look something like this:</p>
  
  <pre><code>PersonID | Account Type 1 Bal | Account Type 2 Bal | Account Type 3 Bal |
  -------------------------------------------------------------------------
      1    |         $100       |         null       |         null       |
      2    |         null       |         $12        |         $1300      |
      3    |         null       |         null       |         $5         |
      4    |         $150       |         null       |         null       |
      5    |         $65        |         $300       |         $45        |
  </code></pre>
  
  <p>I would assume I would use some sort of case statement, but I haven't been able to figure it out yet. Also, if they have multiple of the same account type, i assume I would just use sum() correct?</p>
  
  <p>Thanks.</p>