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 8107613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:49:54+00:00 2026-06-06T00:49:54+00:00

I have a weird problem. When I execute a query the data is not

  • 0

I have a weird problem. When I execute a query the data is not displayed in the Resultset however when I click on the column header in the ResultSet to sort it, the row appears.

My table looks like this –

id     user_id  action_id   object_id   MAX(s.timestamp)
2825    61  2   806 16/06/2012 03:41:55
2818    208 4   0   15/06/2012 15:11:30  -- problematic row
2817    21  7   1   15/06/2012 13:18:38
2816    208 4   0   15/06/2012 12:11:30  -- problematic row
2803    320 9   806 14/06/2012 23:14:32
2802    320 9   805 14/06/2012 17:15:54
2801    208 4   0   14/06/2012 15:11:30  -- problematic row

I am using the following query –

SELECT  MAX(activity_stream_id) id,
        s.user_id,
        s.action_id,
        s.object_id, 
        MAX(s.timestamp)
FROM pp_activitystream s
GROUP BY s.user_id, s.action_id, s.object_id 
ORDER BY s.timestamp DESC

Ideally, in the ResultSet I should get the top most of the “problematic row” but i do not.
When I click on the column header to sort the row, the “problematic row” appears.

Can you tell me why is it behaving like this?

I executed the above query using Toad and MySQL Workbench and it behaves the same way.

Output after execution –

id     user_id  action_id   object_id   MAX(s.timestamp)
2825    61  2   806 16/06/2012 03:41:55
2817    21  7   1   15/06/2012 13:18:38
2803    320 9   806 14/06/2012 23:14:32
2802    320 9   805 14/06/2012 17:15:54

Output after clicking on any column header to sort (timestamp in this case) –

id     user_id  action_id   object_id   MAX(s.timestamp)
2825    61  2   806 16/06/2012 03:41:55
2818    208 4   0   15/06/2012 15:11:30  -- row appears
2817    21  7   1   15/06/2012 13:18:38
2803    320 9   806 14/06/2012 23:14:32
2802    320 9   805 14/06/2012 17:15:54
  • 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-06-06T00:49:55+00:00Added an answer on June 6, 2026 at 12:49 am
    SELECT  MAX(activity_stream_id) id,
            s.user_id,
            s.action_id,
            s.object_id, 
            MAX(s.timestamp) as ts
    FROM pp_activitystream s
    GROUP BY s.user_id, s.action_id, s.object_id 
    ORDER BY ts DESC
    

    Mysql lets you use non-grouped columns among selected columns, and non-selected columns in order by clause. Even if that sometimes might feel sexy or useful (at least to me), it is conceptually flawed, and may lead to errors very difficult to spot.

    In this case you are trying to order on a column that appears as an aggregate column in select, leading to unpredictable results. When you click on the resultset table header in toad or mysql-workbench, you actually telling mysql to order on MAX(timestamp), making things work fine.

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

Sidebar

Related Questions

I have a weird problem with my mysql query syntax. I have made a
I have another weird problem which I have not been able to solve in
I have a very weird problem while trying to pass and SQL query using
I have a weird problem with my sql script. I have a string $query
I have a weird problem, I cant execute bash script even as basic as:
I have run into a rather weird problem. I have created the following query
I have a weird problem with a Java Gregorian Calendar: SimpleDateFormat sdf = new
I have a weird problem, so I thought I would ask and see if
I have a weird problem. I create this window, but its blank until i
I have a weird problem where after setting nocheck on a foreign constraint and

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.