2009/11/28 Michael Bayer <mike...@zzzcomputing.com>: > we support CASE via case() which will get you there just as well. > > > On Nov 28, 2009, at 1:54 PM, Diego Woitasen wrote: > >> Does sqlalchemy support SQL IF? For example: >> >> select date, if(proxy_user_id <> 1, count(distinct address_id), 0) >> from table group by date; >> >> I've solved this using literal SQL in Query() parameters but may be I >> can do it using ORM. >> >> >> -- >> Diego Woitasen >> XTECH >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to sqlalch...@googlegroups.com. >> To unsubscribe from this group, send email to >> sqlalchemy+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/sqlalchemy?hl=en. >> >> > > -- > > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > >
I discovered that func.if_() works. count_ip = func.if_(MiniAccess.proxy_user_id == dash_id, func.count(MiniAccess.address_id.distinct()), 0) I looks like func.foo() are translated to SQL FOO(), with the same arguments. -- Diego Woitasen XTECH -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.