方法一,用row_numberpython
分組爲1,在組內編號排序。排序
代碼 select row_num(a.num) num,
event_query,
search_num
from
(
select '1' as num,
event_query,
search_num
from
(
SELECT event_query
,count(1) AS search_num
FROM default.table
WHERE event_day = '20150406'
GROUP BY event_query
SORT BY search_num DESC
LIMIT 100
)a
)aa
ip
2 .方法二,用pythonevent
每一行添加一個字段輸出table
import sys
num=0
for line in sys.stdin:
line = line.strip()
if line!="":
num=num+1
print("%d\t%s") %(num,line)效率
top100的數據中添加序號字段,推薦方法二,效率高。import