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
 
Mark Van De Vyver  
View profile  
 More options Nov 6 2007, 2:18 am
From: "Mark Van De Vyver" <mvy...@gmail.com>
Date: Tue, 6 Nov 2007 18:18:38 +1100
Local: Tues, Nov 6 2007 2:18 am
Subject: Re: help with aggregation & group by
Hi,
A note on this...

On Nov 6, 2007 4:21 PM, Sharon Rosner <cico...@gmail.com> wrote:

> > Am I best off just executing the SQL above and saving it into a
> > dataset for ruby manipulation?

> Right now yes. You can do that easily:

>   sql = "select market, minute(from_unixtime(ack)) AS minute,
> round(avg((ack -
>   created_at) * 1000), 2) AS ack_average from orders  where 'ack' >
>   (UNIX_TIMESTAMP(now()) - (15 * 60) and 'market' = 'ICE' group by
>   minute(from_unixtime(ack));"

>   dataset = DB[sql]
>   dataset.each {|r| p r}

> I've played with it a bit and right now, field quoting in the mysql
> adapter is broken, so you can't use any functions or formulas in
> #select, #group etc. Ultimately our goal should look like this:

>   market = 'ICE'
>   ack_stamp = 15.minutes.ago
>   Order.query do
>     select do
>       :market,
>       :minute[:from_unixtime[:ack]].AS :minute
>       :round[:avg[(:ack - :created_at) * 1000], 2].AS :ack_average
>     end
>     where do
>       :ack > ack_stamp
>       :market == market
>     end
>     group_by :minute[:from_unixtime[:ack]]
>   end

... the following presentation (discussed on the Nitro mail list) and
the code beneath it illustrate a neat implementation of just this sort
of thing.  It seems very elegant and it would simplify the above
syntax, so may be worth looking into?

 http://www.xaop.com/articles/2007/10/07/metaprogramming

HTH
Mark

> With the help of ParseTree I think it's possible to do that, and also
> to fix field quoting. Can you please open an issue for this?

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