Try using HAVING
clause:
SELECT sportsID, newsID, cID, SUM(likes) AS totalLikes
FROM like_table
GROUP BY sportsID, newsID
HAVING SUM(likes)> 0
ORDER BY totalLikes DESC
Explanation:
The HAVING
clause was added to SQL because the WHERE
keyword could not be used with aggregate functions.
The WHERE
clause places conditions on the selected columns, whereas the HAVING
clause places conditions on groups created by the GROUP BY
clause.