Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7692153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:47:15+00:00 2026-05-31T20:47:15+00:00

This is the correct ordered array with MySQL: [ [1330210800000, 1], [1330297200000, 6], [1330383600000,

  • 0

This is the correct ordered array with MySQL:

[
  [1330210800000, 1],
  [1330297200000, 6],
  [1330383600000, 10], 
  [1330470000000, 2],
  [1330556400000, 5],
  [1330815600000, 9],
  [1331593200000, 2], 
  [1331852400000, 4],
  [1331938800000, 8],
  [1332111600000, 8],
  [1332198000000, 4], 
  [1332284400000, 8],
  [1332370800000, 3], 
  [1332630000000, 2] 
]

But with PostgreSQL the array is:

[
  [1330588800000, 5], 
  [1332399600000, 3], 
  [1330848000000, 9], 
  [1330416000000, 10], 
  [1331622000000, 2], 
  [1330329600000, 6], 
  [1330502400000, 2], 
  [1332140400000, 8], 
  [1332313200000, 8], 
  [1330243200000, 1], 
  [1332226800000, 4], 
  [1331967600000, 8], 
  [1332658800000, 2], 
  [1331881200000, 4] 
]

The postgreSQL is the order wrong and the dates different and the count of kliks:

This is the query in my controller:

@kliks = Klik.count( :group => "DATE( created_at )" )
         .map{|k, v| [(Time.parse(k).to_i * 1000), v] }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:47:16+00:00Added an answer on May 31, 2026 at 8:47 pm

    You haven’t specified any particular order in your query so the database is free to return your results in any order it wants. Apparently MySQL is ordering the results as a side effect of its GROUP BY but PostgreSQL won’t necessarily do that. So your first “bug” is just an incorrect assumption on your part. If you want the database to do the sorting then you want something like:

    Klik.count(:group => 'date(created_at)', :order => :date_created_at)
    

    If you throw out the * 1000 and sort the integer timestamps:

    1330210800, 1,  MySQL
    1330243200, 1,  PostgreSQL
    
    1330297200, 6,  MySQL
    1330329600, 6,  PostgreSQL
    
    1330383600, 10, MySQL
    1330416000, 10, PostreSQL
    
    ...
    

    You’ll see that they do actually line up quite nicely and the integer timestamps differ by 32400s (AKA 9 hours) or 28800s (AKA 8 hours or 9 hours with a DST adjustment) in each MySQL/PostgreSQL pair. Presumably you’re including a time zone (with DST) in one of your conversions while the other is left in UTC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What do you think? Is this correct or are there memory leaks? Source: #include
I'm confused with bridge and bridge_transfer , is this correct? -(void)getData{ ABAddressBookRef addressBook =
In PHP, filter_var('www.example.com', FILTER_VALIDATE_URL) returns false . Is this correct? Isn't www.example.com a valid
Is this the correct way to do it? <a id=load href=# class=btn load onclick=request(this);
Is this the correct (or even a valid way) to use emums in Objective-C?
Is this the correct way to obtain the most negative double in Java? double
This is a simple question: Is this a correct way to get an integer
Is this code correct? I'm trying to submit it and also I would like
Is this the correct/best SPARQL query to get the count of items in rdf:list:
A function of mine produces an array - an ordered, contiguously numbered set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.