On Sun, Nov 15, 2009 at 1:45 PM, André Allavena
<[email protected]> wrote:
>
> 2009/11/15 Gavin Kistner <[email protected]>:
>>
>> On Nov 15, 2009, at 3:25 AM, André Allavena wrote:
>>> I'm doing are a little different (I often need to go down to SQL to do
>>> things like select sum(col1 - col2) group by col 3
>>
>> FWIW:
>>
>> irb(main):001:0> require 'sequel'
>> => true
>>
>> irb(main):002:0> DB = Sequel.sqlite; DB.quote_identifiers = false
>> => false
>>
>> irb(main):003:0> DB[:foo].select( :sum.sql_function(:col1 - :col2) 
>> ).group_by( :col3 )
>> => #<Sequel::SQLite::Dataset: "SELECT sum((col1 - col2)) FROM foo GROUP BY 
>> col3">
>
> What I need is
> SELECT col3, sum((col1 - col2)) FROM foo GROUP BY col3"
> otherwise, I don't know what sums corresponds to what.

DB[:foo].select(:col3, :sum[:col1-:col2] => :val).group_by(:col3)

>
> Is there a case to be made for this actually being the behaviour? I'm
> not certain what the usage of the group by without knowing which group
> corresponds to what.
>
> André
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to