Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion help with aggregation & group by
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sharon Rosner  
View profile  
 More options Nov 6 2007, 4:40 am
From: Sharon Rosner <cico...@gmail.com>
Date: Tue, 06 Nov 2007 01:40:08 -0800
Local: Tues, Nov 6 2007 4:40 am
Subject: Re: help with aggregation & group by

> from   :c => Customer, :b => Bank, :a => Account
>   select b.name
>   where  ((c.firstname == first1) |
>           (c.firstname == first2)), etc.

> appeared simpler than having blocks and .AS, but no doubt there is a
> limit to his approach I'm unaware of.

Actually for that kind of thing you can specify your filter as a hash:

  where(:firstname => [first1, first2])

Notice how you can provide an array and Sequel takes care of
constructing the filter. Also gives you nicer-looking SQL:

  ... WHERE firstname IN ('john', 'george')

If you need to qualify the field name you can use the special symbol
notation:

  where(:c__firstname => [first1, first2])

Sequel also lets you use any comparison operator, not just ==:

  where {:price > 100}

You can also specify mathemtic expressions and compare against other
fields:

  where {:price < :avg[:price] - 100}

Have a look at the cheat sheet:

  http://code.google.com/p/ruby-sequel/wiki/CheatSheet

sharon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.