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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:24:48+00:00 2026-05-18T00:24:48+00:00

I am unsure on how to google this, so let me just try to

  • 0

I am unsure on how to google this, so let me just try to explain. Train numbers are a slot in a timetable, and hence repeat everyday. For each train, there are a set of events from start to finish, and those events include a value for the current weight.
What I would like to find out is the peak per train. If I just wanted the peak, it would just be a select *, max(weight)…, but I want it done by train number so that I can get the date/time and station name.
I want something along the lines of:

SELECT train, weight, date, station FROM event_table  WHERE date >= '2010/10/03' 
  AND date <= '2010/11/03' ORDER BY weight DESC LIMIT 1 GROUP BY train

But obviously the GROUP BY can’t be after the limit. My option is ignoring the limit and filtering it out in PHP, but it’s wasted cycles and bandwidth, which might be a problem in the future.

Thanks

  • 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-18T00:24:49+00:00Added an answer on May 18, 2026 at 12:24 am

    As an alternative to Randy’s answer you use Join syntax.

    SELECT * 
    FROM 
    event_table   et
    INNER JOIN (
        SELECT 
            train, 
            Max(weight) weight
        FROM 
           event_table  
        WHERE date >= '2010/10/03' 
          AND date <= '2010/11/03' 
        GROUP BY train) max 
    ON et.train = max.train  and et.weight = max.weight
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It just appears like this in Google Chrome: <html> <head> <title>Hello World!</title> </head> <body>
Unsure how to get this string to work correctly. Keeps making my page blank.
I'm a little unsure of how to ask this question, so I'll start as
I am unsure why this code will not work. When I click a button
This feels like a too easy question to be found with google, I think/hope
This solution must use the google closure javascript library and not any other javascript
I am unsure whether this problem is in Django or HTML, so I'm including
I'm unsure how to refer to this (so I can't search for it by
I am unsure whether this question belongs here, so please feel free to migrate
Unsure exactly how to put this question so apologies for the awkward phrasing, generally

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.