Weird sort

Hi guys: Having this strange problem using Rails on Postgres. I’m trying
to count up the records that match a certain created_at date, but they
don’t seem to be grouping in order. Tip: this worked fine in MySQL, but
I need to use Heroku, which is Postgres only…

Here is my query:

@graphdata = Capture.count(:group =>
“to_char(created_at,‘YYYYMMDD000000’)”, :conditions => “created_at
between '”[email protected]+"’ and ‘"[email protected]+"’ and ("[email protected]+")",
:select => “created_at”)

But when I try to output this, the order is all wonky:

20100302000000:994<
20100222000000:2964<
20100227000000:4853<
20100301000000:7143<
20100226000000:5340<
20100223000000:3517<
20100221000000:196<
20100225000000:4485<
20100224000000:4068<
20100228000000:15335<

Any ideas? I tried adding :order to the query and it broke…

Thanks…Chris

What was in your :order argument?

Did you specify it as :order => “to_char(created_at,
‘YYYYMMDD00000’)” ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs