Mysql
 sql >> Datenbank >  >> RDS >> Mysql

eine harte Abfrage, um mir in MySQL zu schreiben?

SELECT content_id,
       SUM(CASE WHEN value=1 THEN 1 
                WHEN value=0 THEN -1 
                ELSE 0 
           END) AS ContentSum
    FROM votingapi_vote
    WHERE value_type = 'option'
    GROUP BY content_id
    ORDER BY ContentSum DESC