limiting consecutive values of one column in a sql query.
- by Brad Smith
I have a table with the following structure:
id -int(11)
event_id -int(11)
photo_id -int(11)
created_at -datetime
How do I write a query that will return the 100 most recent rows, but insuring that there are no more than 4 consecutive rows with the same value in photo_id