How to get rank according to count in mysql
<p>I am getting issue with fetching the rank according to the count.</p>

<p>I have two tables :</p>

<pre><code>1)images
2)images_like
</code></pre>

<p>Now if the images_like have no entries then it is showing "NULL" in the ranks. please check the query  and output :</p>

<pre><code>SELECT im.id, 
   rank 
FROM   (SELECT image_id, 
               @rownum := @rownum + 1 AS rank, 
               Count(*)               AS cnt 
        FROM   images_like, 
               (SELECT @rownum := 0) r 
        GROUP  BY image_id 
        ORDER  BY `cnt` DESC) AS d 
       RIGHT JOIN images AS im 
               ON d.image_id = im.id 
</code></pre>

<p><a href="https://i.stack.imgur.com/WTfpn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WTfpn.png" alt="enter image description here"></a></p>

<p>i need to display 3 not null ....</p>

<p>Thanks in advance !!!!!</p>