You could also include a creation and/or modified time in each record and reverse sort by that.
On Tuesday, May 20, 2014 10:16:54 AM UTC-4, Johann Spies wrote: > > > > > On 20 May 2014 16:11, Tom Russell <tsrdatat...@gmail.com> wrote: > >> I have a table which I insert data from the internet, just 4 records. >> Before inserting though I need to get the last 5 rows of data from these 4 >> fields and do a calculation with them. Then when I insert the data I add >> one more field making it a total of 5 fields I am inserting into the db. >> These 5 fields exist already so nothing odd there. >> >> My main issue is just getting the last 5 records from the db. Is there a >> better way to get that data with the DAL? It kind of appears to me that I >> could possibly use limitby to get these as well? >> >> > > last_five_records = db(db.sometable.id > > 0).select(db.sometable.the_fields_you_want_to_work_with, orderby=~ > db.sometable.id, limitby = (0,4)) > > Regards > Johann > > -- > Because experiencing your loyal love is better than life itself, > my lips will praise you. (Psalm 63:3) > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.