Selecting rows ordered by foreign key count and filtering by date
So this is happening because even though you used a LEFT JOIN, you're filtering on a field in the right-side table of that LEFT JOIN in the part of your query that does WHERE v.&quot;createdAt&quot; &gt;= '2020-01-01 00:00:00' so this removes all the records in your left-side table &quot;Server&quot; where there are no rows it could join to in the &quot;Vote&quot; table (i.e. where createdAt is null).
You can add this additional condition in your WHERE predicate to fix that:
SELECT s.id, s.title, s.content, count(&quot;serverId&quot;) AS &quot;voteCount&quot; 
FROM &quot;Server&quot; AS s 
LEFT JOIN &quot;Vote&quot; AS v ON (s.id = &quot;serverId&quot;) 
WHERE v.&quot;createdAt&quot; &gt;= '2020-01-01 00:00:00' 
    OR v.&quot;createdAt&quot; IS NULL
GROUP BY s.id ORDER BY &quot;voteCount&quot; DESC;