Hi, I believe all you want is execute some of your own sql code inside web2py.
If I am right , all you need to have to do is run your query and catch return value into 'results' 1/ results=db.executesql(your-sql-query-goes-here) to send it to the view 2/ return dict(results=results) once here (in your view) you might want to present the results automagically using : 3/ SQLTABLE(results) by the way 'results' is an object called gluon.sql.Rows and is composed of child objects called gluon.sql.Row (each one of them) that said SQLTABLE accepts the first one => gluon.sql.Rows but you can as well build your own table in your view like this ; <table><tr> <td> first_column</td><td>second_column</td><td>third_column</td> </tr> {{for result in results;}} <td>{{=result[0]}}</td> <td>{{=result[1]}}</td> <td>{{=result[2]}}</td> {{pass}} </table> the only draw back is that HTML5 will be very angy at you because you did not include tbody and tfoot ;) khalil