I have a table called trends_points , this table has the following columns:
- id (unique identifier for the string)
- userId (identifier of the user who entered this into the table)
- term (word)
- time (unix timestamp)
Now I'm trying to run a query in this table that will receive rows in a certain time interval, ordered by how many times the term column appears in the table during a certain timeframe ... So for example, if the table has the following rows:
id | userId | term | time ------------------------------------ 1 28 new year 1262231638 2 37 new year 1262231658 3 1 christmas 1262231666 4 34 new year 1262231665 5 12 christmas 1262231667 6 52 twitter 1262231669
I would like the lines to go like this:
new year christmas twitter
This is because “New Year” exists three times in the timeframe, “Christmas” exists twice, and “Twitter” - only on one line.
So far, I have requested this simply WHERE for the specific part of the time request and GROUP BY so that the same term does not return twice in the list.
This makes the following request:
SELECT * FROM `trends_points` WHERE ( time >= <time-period_start> AND time <= <time-period_end> ) GROUP BY `term`
Does anyone know how I will do the final part of the request? (Ordering query results for how many rows contains the same value for the "term" .. column).
source share