2009/11/26 Jeremy Evans <[email protected]>

> On Nov 26, 8:04 am, Christer Nilsson <[email protected]>
> wrote:
> > I'm *very* pleased with Sequel, but have one minor question:
> >
> > Is it possible to produce the following sql with Sequel?
> >
> > SELECT activityID, *sum*(hours) as hours FROM tbltime WHERE activityID IN
> > (42,4711) *GROUP* BY activityID
> >
> > Trying TblTime.filter(:activityID =>
> > [42,4711]).group(:activityD).sum(:hours)
> >
> > I got SELECT sum(hours) as hours FROM tbltime WHERE activityID IN
> (42,4711)
> > GROUP BY activityID LIMIT 1
> >
> > which returns 1x1 cell instead of expected 2x2
> >
> > How do I use sum in .select ?
> >
>
> TblTime.filter(:activityID => [42,4711]).group(:activityID).select
> {[activityID, sum(hours).as(hours)]}
>
> Jeremy
>
> Yes, it works!

Is the part after .select a hash or a block?
And why are the column names not symbols?
The syntax is ok, I just wan't to understand what's going on.

Christer

--

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