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
 
Chuck Remes  
View profile  
 More options Nov 6 2007, 7:05 am
From: Chuck Remes <cremes.devl...@mac.com>
Date: Tue, 6 Nov 2007 06:05:54 -0600
Local: Tues, Nov 6 2007 7:05 am
Subject: Re: help with aggregation & group by

On Nov 5, 2007, at 11:21 PM, Sharon Rosner 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}

This is the method I'm using right now. It's somewhat ugly but still  
very functional!

> 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

Ooh, that's pretty!

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

Just opened it. Listed as Defect #88.

I'll take a stab at providing some of this functionality but it means  
learning ParseTree and probably ruby2ruby which might be a bit beyond  
my ruby capabilities right now. Don't hold your breath waiting for my  
patch... ;-)

cr


 
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.