title: How to count students and classes of every teacher in SQL Server?
body: <p>Assume 3 tables like this:</p>
  
  <p><strong>Teacher:</strong> </p>
  
  <pre><code>teacher_id, name, ... 
  </code></pre>
  
  <p><strong>Student:</strong> </p>
  
  <pre><code>student_id, teacher_id, ... 
  </code></pre>
  
  <p><strong>Class:</strong> </p>
  
  <pre><code>class_id, teacher_id, ... 
  </code></pre>
  
  <p>Is there a SQL query to get how many students and classes are assigned to every teacher? </p>
  
  <p>Result should be something like this:</p>
  
  <pre><code>teacher_id  name    students    classes 
  t_001       AAA        3           2 
  t_002       BBB        1           2 
  ...
  </code></pre>