The SQL command would be SELECT COUNT(DISTINCT item.of_variant) FROM item;
but I believe that is not something you can build in the DAL currently. In addition that SQL command might not be supported by all the backend DBs. It seems to work in SQLite and MS-SQL though. So you have two options: 1) len( db().select(db.item.of_variant, distinct=True) ) 2) db.executesql('SELECT COUNT(DISTINCT item.of_variant) FROM item;') if it is supported by the DB you are using. On Jan 28, 7:32 am, vortex <billyara...@gmail.com> wrote: > How to do a count distinct with DAL? > > like: > > db().count(db.item.of_variant, distinct=True)