title: How to get total count from one of the inner join queries?
body: <p>I have written the following MYSQL query and the The Mysql version is <code>8.0.18-commercial</code></p>
  
  <pre><code>SELECT p.server, 'Type1' AS Check_Type, 
         GROUP_CONCAT(vmtable.res SEPARATOR ', ') AS result
  FROM server p 
  INNER JOIN truns t ON t.oq_id = p.oq_id
      AND t.id = (SELECT t2.id FROM truns t2 
                  WHERE t2.oq_id = p.oq_id 
                  order by t2.created_at desc limit 1 )
  INNER JOIN qvuln_info vmtable ON vmtable.run_id = t.id 
  LEFT JOIN qvuln_info_data vmtableinfo ON vmtableinfo.qid = vmtable.qid   
  WHERE p.server regexp 'server1'
  GROUP BY p.server
  </code></pre>
  
  <p>I am getting output as:</p>
  
  <pre><code>Hostname   Check_Type  result
  server1    Type_ABC    Result 1,Result 2,Result 3,Result 4
  </code></pre>
  
  <p>I want to add another column as <code>VulCount</code> at the top level and that value should come from one of the inner join queries:</p>
  
  <pre><code>SELECT t2.id 
  FROM truns t2 
  WHERE t2.oq_id = p.oq_id 
  order by t2.created_at desc
  </code></pre>
  
  <p>The output should look as below:</p>
  
  <pre><code>Hostname   VulCount    Check_Type  result
  server1    4            Type_ABC       Result 1,Result 2,Result 3,Result 4
  </code></pre>
  
  <p>Here, <code>4</code> is output of </p>
  
  <pre><code>SELECT count(*) 
  FROM truns t2 
  WHERE t2.oq_id = p.oq_id 
  order by t2.created_at desc
  </code></pre>