通过选择不同的计数行我有一个表hastags
降序
id|tweet_id| tag |time
1 1 hell
2 2 hellyeah
3 3 hell
4 4 stackoverflow
5 5 hell
6 6 hellyeah
7 7 bellrings
8 7 nomorehell
8 7 nomorehell
我想选择一个特定时间以上的最常用tags
计数。 现在,如果我限制我的查询,以3行我应该得到
|tag | count|
hell 3
hellyeah 2
nomorehell 2
我怎样才能做到这一点任何帮助吗?
现在如果我想结合到特定的时间意味着..........................'选择标记,计数(*)作为计数 从#标签 其中'time'> '2014年12月29日' 组由标签 为了通过计数递减 限制3'和'选择标签,COUNT(*)作为计数 从主题标签 其中'time'>“2013-12 -29'AND'time' <'2014-12-29' group by tag order by count desc limit 3'那怎么办? –
我更新了答案。总结条件。但是你必须选择你想用来排序的列。 –
第一个和第二个将有相等的行数? –