And then I realised that I was barking up the wrong tree. Too used to mysql's if(cond,true_val,else_val) syntax I didn't even check if postgressql even know the same thing. Newsflash; it doesn't.
Instead, it has the 'case' expression. To be found in the sqlalchemy.sql.expressions module. On Apr 5, 9:03 pm, Wouter van Vliet <wou...@interpotential.com> wrote: > Thanks for your suggestion, but no such luck. From the sql error I get > I gathered that that just creates an actual if_ function.. > > On Apr 5, 9:08 pm, a...@svilendobrev.com wrote: > > > try with func.if_(....) > > > On Sunday 05 April 2009 21:19:29 Wouter van Vliet wrote: > > > > Hi Folks, > > > > After an hour or so of browsing the net and documentations, getting > > > increasingly frustrated and being about to just - nah, I didn't > > > really consider throwing sqlalchemy out of my project. But still. > > > Anyway, I'm trying to make a select-query which would send > > > something like this to postgres: > > > > SELECT sum(if(type = "purchase", value, 0)), user_id > > > FROM transactions > > > GROUP BY user_id > > > > But no matter how hard I try, I can't find something that works > > > like just being able to do > > > > sql.func.if( ... ) > > > > when I do that, I get the obvious syntax error. > > > > Any help is much appreciated. > > > Wouter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---