You can use the sql_expr extension and do > > filter((Date.today - 60).sql_expr > last_printed). > > Nice. I'll read up on sql_expr and learn a little more about it. Haven't used it thus-far.
> I also tried redefining last_printed as: > > > > last_printed = DB[:'billing history']. > > filter(:billing => :billing). > > max(:'date printed') > > The filter is pointless, unless you are attempting to remove NULL > I was attempting to feed the billing column from the billing header into stale_billings "sub-query style" such that it was evaluated with candidate row of the billing header, which obviously wasn't the result I got. This should give you all billings that have a positive balance and > haven't been billed in the last 60 days: > > Hopefully that should be enough to get you started. If you have > further questions, please let me know. > > Thanks. I had to spend a little bit of time just understanding that one. I actually never really thought about joining on a select clause as opposed to straight up table joins before. Nice trick there. I just had to slip a group(:billing) on that joined statement and got it working. This is *much* faster query-wise than the hacky solution I had going. Regards, 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.
