I omit the steps before the last one. I get the table like: year, month, postid, clicks. How do I get top-k postid for each year, month group?
For example, I have data:
2012,1,a,5
2012,1,b,3
2012,1,c,8
2012,2,a,2
2012,2,c,5
2012,2,d,6
Assuming k=2, I want the results like:
2012,1,c,8
2012,1,a,5
2012,2,d,6
2012,2,c,5
Give this a try:
Fiddle here