The following is from a recent support session. Check it out!

Frank

Add CountSQL to "Invalid SQL" error to clarify. Many time, user do not know that Tornado tried to guess the dbCountSQL to obtain he record count. In complex case especially involving DISTINCT, the guess is not correct. In this case, use dbCountSQL. See following SQL -

.dbSQL = "select DISTINCT * from ORDERS WHERE customerID='Vinet'"

Now, you'll see the incorrect countsql in the Error display and you should then use -

.dbCountSQL = "select DISTINCT count(*) from ORDERS WHERE customerID='Vinet'"

Note this example only fails in SQL but works in ACCESS. So, it is better to supply your own accurate CountSQL.