title: SQL write a query, question from interview problem
body: <p>At the beginning I need to mention that I am not very good at SQL so I would like to ask you.</p>
  <p>Here is a tables relation:</p>
  <p><a href="https://i.stack.imgur.com/REG6R.jpg" rel="nofollow noreferrer">tables</a></p>
  <p>What I need to do with them is &quot;Show name, surname and number of movies those directors (Reżyser means director), who made more movies that the average number is for all directors. Sort results from the biggest to the smallest.&quot;</p>
  <p>Here's what I tried:</p>
  <pre><code>select r.NAME, r.SURNAME, count(*) as counter group by (r.NAME, r.SURNAME) having count &gt; avg(*) orderby DESC;
  </code></pre>
  <p>but I got only 2/10 points from recruiter.</p>