This works perfect in SQLite:

   rows = db(query).select(db.cart_sharing.created_by.with_alias('sharer'),
                           db.cart_sharing.stats.count().with_alias('carts'
),
                           db.cart_sharing.stats.sum().with_alias('shares'),
                           groupby=db.cart_sharing.created_by,
                           orderby=['~shares'])


'shares' is alias to sum(), and sqlite understands exactly what's needed - 
sorts by the number of shares. 

Posgres doesn't like it: 
      <class 'psycopg2.ProgrammingError'> column "shares" does not exist 
LINE 1: ...NULL) GROUP BY "cart_sharing"."created_by" ORDER BY ~shares; ^

What's the proper DAL syntax for such a thing compatible with Postgres? 


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c3bfb0ea-6c29-48d8-85a3-3e4e21242b9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to