通過選擇不同的計數行我有一個表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'那怎麼辦? –
我更新了答案。總結條件。但是你必須選擇你想用來排序的列。 –
第一個和第二個將有相等的行數? –