create table posts (
    id serial primary key,
    view_count integer default 0 not null,
    vote_count integer default 0 not null
);
 
create index on posts((case view_count when 0 then 0 else vote_count::float / 
view_count end));
 
class Post(SQL_DB.meta):
    __table__ = sa.Table('posts', SQL_DB.meta.metadata, autoload=True)
 
I need to query Post, ordered by vote_count/view_count with use of index.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to