Am assuming you want the last two records in a table all the time, and
they correspond to the variables A, B.
If you know the number of records in that table, via the count method,
or a more efficient mechanism, then you can use the limitby statement to
get the last two records.
|
total_records = #number of records in the test table - computed via
count, or some other method
[A,B] =db().select(db.test.ALL, limitby(total_records - 3, 2)
|
________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/
On Thu, 08-01-2015 10:56 AM, Timo Bahner wrote:
Hi guys.
Let's assume the following table
|
db.define_table('test',Field('letter','double'))
|
How can I compare two 'letter' entries if for example
|
A=1.23
B=4.56
|
To get the last entry (B) I'll use
|
last_entry =db().select(db.test.ALL).last()
|
*But how do I get the entry before the last, in this case letter A?*
The actual comparing will be done within index.html to check if B is
greater or equal to A for example
|
{{ifB >=A:}}
<!--some html code-->
{{else:}}
<!--some html code-->
{{pass}}
|
--
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 [email protected]
<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.