Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Selecionando registros na ordem do número de registros que contêm um determinado campo

SELECT Album_ID, COUNT(*) AS NumVotes 
    FROM wp_album_votes 
    WHERE YEARWEEK( Time_Voted ) = YEARWEEK( CURRENT_DATE - INTERVAL 7 DAY ) 
    GROUP BY Album_ID
    ORDER BY NumVotes DESC LIMIT 5