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, 12:21 am
From: Sharon Rosner <cico...@gmail.com>
Date: Mon, 05 Nov 2007 21:21:31 -0800
Local: Tues, Nov 6 2007 12:21 am
Subject: Re: help with aggregation & group by

> 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

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.