title: cakephp 3.4 mySQL to orm convert
body: <p>my Current MYSQL query is </p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT
      cl.user_id,
      COUNT(q.id) as completed_questions,
      (
          SELECT
              SUM(points) 
          FROM
              completed_levels 
          WHERE
              user_id = cl.user_id 
      )
      as level_point 
  FROM
      completed_levels cl 
      JOIN
          questions q 
          on q.level_id = cl.level_id 
  GROUP BY
      cl.user_id;
  </code></pre>
  
  <p>my current ORM is following i just not able to handle select part in </p>
  
  <pre><code>$completedLevels = TableRegistry::get('CompletedLevels');
  $completedLevels = $completedLevels-&gt;find('All');
  $completedLevels = $completedLevels
      -&gt;contain(['Users', 'Levels'])
      -&gt;select([
          'user_name' =&gt; 'Users.name',
          'count_questions' =&gt; 'COUNT(Questions.id)',
          'total_pints' =&gt; [
              'select'=&gt;'SUM(CompletedLevels.points)'
          ]
      ])
      -&gt;join([
          'table' =&gt; 'Questions',
          'conditions' =&gt; 'Questions.level_id = CompletedLevels.level_id',
      ])
      -&gt;group(['CompletedLevels.user_id'])
      -&gt;all();
  </code></pre>