Hello everyone, I have a few tables structured like this:
db.define_table('question_table', Field('qid'), Field('display_text'), ) db.define_table('answer_table', Field('qid'), Field('value'), Field('display_text'), ) db.define_table('data', Field('qid'), Field('value') ) What I am doing is getting all unique values from the data table, getting the display_text from the answer_table and displaying a table of the display_text and how many times it was present in the data table. here's my functioning code results = [] for row in db(db.data.qid == qid).select(db.data.value, distinct=True): results.append([db((db.answer_table.value == row.value) & (db.answer_table.qid == qid)).select().first().display_text, db((db.data.qid == qid) & (db.data.value == row.value)).count()]) i'm hoping there's some way to get this in a more straightforward fashion, or in a way that would optimize performance. Thank you for the help you can give! Jason -- 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.