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

Selezione dei record in base al numero di record che contengono un determinato 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