Quantcast
Channel: MYSQL: closest to supplied date grouped by user_id - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by David Ritchie for MYSQL: closest to supplied date grouped by user_id

Try this subquery instead. The organisation_id/framework_id/level_id filter is moved into the subquery and it now returns the right values for the examples you've given.SELECT t1.id, t1.user_id,...

View Article



Answer by Gordon Linoff for MYSQL: closest to supplied date grouped by user_id

I think this does what you want:SELECT f.id, f.user_id f.date_added FROM completed_frameworks fWHERE date(f.date_added) <= '2025-09-07' -- or whatever your date isORDER BY f.date_added DESCLIMIT...

View Article

Answer by Tim Biegeleisen for MYSQL: closest to supplied date grouped by user_id

Here is a sample query you could use for an input date of '2015-09-07 14:13:39'. The inner query returns the input date along with the next highest date. This temporary table is then used to filter...

View Article

MYSQL: closest to supplied date grouped by user_id

I need to get multiple rows with a date_added closest to but not past a user supplied date, grouped by user_id.I've looked at a bunch of max in group type answers but I'm not quite there:Get nearest...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images