Grouping MYSQL results by multiple columns and time span -
How do I enter one, most recent If today is 11th July, the following table This will produce: < Previous> In the last 7 days, most recent < Code> NID for each user is I'm assuming, the group will be tricked; But I have no clue from where it is starting. UPDATE The query is based on the top question: NID , every 7 days per, per
+ ----- + ----- ------- + - ---- + | NID | Timestamp | UID | + ----- + ------------ + ----- + | 1 | 1341719851 | 8 | // July 7 | 2 | 1341115051 | 8 | // July 1 | 3 | 1341547051 | 8 | // July 6 | 4 | 1341719851 | 8 | // July 8 | 5 | 134197 9 5151 | 8 | // July 11 | 6 | 1341806251 | 9 | // July 9 | 7 | 1341460651 | 9 | // 5th July | 8 | 1341892651 | 9 | // July 10 + ----- + ------------ + ----- +
+ ----- + ------------ + ----- + | NID | Timestamp | UID | + ----- + ------------ + ----- + | 2 | 1341115051 | 8 | // July 1 | 5 | 134197 9 5151 | 8 | // July 11 | 8 | 1341892651 | 9 | // 10 July ----- + ------------ + ----- +
'5' and
'8' , in the first 7 days, the most recent
NID Is
'2' , and so on ...
SELECT nid, timestamp, UID, SELECT nid, timestamp, UID , FLOR ((UNIX_TIMESTAMP (timestamp) / 604800) according to timestamp DESC from time_em to 'Table') X Group UID, Week_A / Pre>
select nid, max (timestamp), from UID, weeks_ago (select nid, timestamp, uid), floor (dated (now () () () (with (), interrupt (timestamp)) From Meritable to Week) X Group NID, UID, Week_Ego
Comments
Post a Comment