douzhicai7148 2013-06-12 14:49
浏览 20
已采纳

从一个月获得总数并限制结果MySQL

I need to make a query that returns the top ten from a month. I hope this is possible directly through MySQL.

Basically I get some data every day (around 150 rows), with some information about different youtubers. Each row has an Identifier, a Date, the YouTuber, and the number of views the youtuber got that day. It looks like this:

ID|Date|Youtuber|Views
126|2013-01-28|example|482612

I need to sum all of the views and to a total, for a month. For example May, and then i need to get the results that has most views for that month.

How would I do that through mysql? Or would I need to use php as well? :)

Cheers

  • 写回答

3条回答 默认 最新

  • dongyanju0945 2013-06-12 14:55
    关注

    SELECT Youtuber, SUM(Views) as viewTotal FROM <TABLE> WHERE month(Date) = 5 GROUP BY Youtuber ORDER BY viewTotal LIMIT 0,10

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画