Mysql
 sql >> Database >  >> RDS >> Mysql

una query difficile da scrivere in MySQL per me?

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