title: How do I join two queries into one using table join
body: <p>This is my first query using table join of two tables sharing the same primary key:</p>
  
  <pre><code>select s.Branch_ID, count(s.Branch_ID)  'No. of Staff', BranchName 'Branch Name'
  from Sales_Staff s , Branch b
  where s.Branch_ID = b.Branch_ID
  group by s.Branch_ID, BranchName
  order by 2 desc
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FWa8i.png" alt="Here is an image of how the output looks like"></p>
  
  <p>This is the second query:</p>
  
  <pre><code>select p.Branch_ID, BranchName, Count(p.Branch_ID) 'Frequency of Packages bought'
  from Payment p, Branch b
  where p.Branch_ID = b.Branch_ID
  Group by p.Branch_ID, BranchName
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/andNF.png" alt="Here&#39;s how the second one looks like"></p>
  
  <p>Now, the output for both was what I expected and wanted. However when I use the same method to join those two queries, the numbers are wrong.</p>
  
  <pre><code>select p.Branch_ID, BranchName, Count(p.Branch_ID) 'Frequency of Packages bought', count(s.Branch_ID) 'No. of Staff'
  from Payment p, Sales_Staff s, Branch b
  where p.Branch_ID = s.Branch_ID
  and s.Branch_ID = b.Branch_ID
  Group by b.Branch_ID, p.Branch_ID, BranchName
  </code></pre>
  
  <p>Incorrect Output
  <img src="https://i.stack.imgur.com/LeKYw.png" alt="Incorrect Output"></p>
  
  <p>Any help would be appreciated.</p>