i think you're looking for CASE.   We have a case() construct which  
creates this.

On Apr 5, 2009, at 3:03 PM, Wouter van Vliet 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to