What does your proposal change in my query constructs?  This is a
typical query for me:

 DB[:billing_details___bd].
   join(:transaction_classes___tc, :tc__transaction_code =>
:bd__transaction_code).
   select{[:bd__billing,
       sum([['C', :extended]].case(0, :transaction_class)).as(:charges),
       sum([['A', :extended]].case(0, :transaction_class)).as(:adjustments),
       sum([['P', :extended]].case(0, :transaction_class)).as(:payments),
       sum(:extended).as(:balance_this_month)]}.
   filter(:bd__entry_date <= end_date).
   group(:bd__billing)

To the above, when I do a "having" clause, it gets a little insane.  ;-)

having(:sum.sql_function([['C', :bd__extended]].case(0,
:bd__transaction_code)) => 0)

would rather do:

having(sum([['C', :bd__extended]].case(0, :bd__transaction_code)) => 0)

(all line items where charges == 0.0)

(and yes, I know I can do having(:charges => 0) if I happen to compute
it and alias it in the select clause...)

Also, instead of excluding like this:

having(~:sum.sql_function(:extended) => 0)

what about:

excluding(sum(:extended) => 0)

Michael
-- 
http://codeconnoisseur.org

-- 
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