开发者

MySQL query advice

开发者 https://www.devze.com 2022-12-28 04:13 出处:网络
I am lost in MySQL documentation. I have a table with votes - it has these columns id song_id user_id created

I am lost in MySQL documentation. I have a table with votes - it has these columns

  • id
  • song_id
  • user_id
  • created

I cannot find the query which will process the information and output the 10 most voted songs in a given time 开发者_Python百科period. What is it?


SELECT id, song_id, COUNT(1) AS total
FROM votes
WHERE created BETWEEN [user_defined_start_date] AND [user_defined_end_date]
GROUP BY song_id
ORDER BY total DESC 
LIMIT 10;


How exactly are you storing the votes? Replace the words in [] below with the variables you want.

select song_id
from [table]
where created > to_date('[the date you want]', '[the format you want]') and created < to_date('[the date you want]', '[the format you want]')
order by [votes]
limit 10;
0

精彩评论

暂无评论...
验证码 换一张
取 消