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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:37:38+00:00 2026-06-08T12:37:38+00:00

I need help with an advanced SQL-query (MSSQL 2000). I have a table called

  • 0

I need help with an advanced SQL-query (MSSQL 2000).

I have a table called Result that lists athletics 100 and 200 meter race-times. A runner can have several racetimes but I want to show only the best time from each runner at each event.

The Result-table contains five columns, Result_id, athlete_id, result_time, result_date, event_code. So athlete_id must be unique when I list the values and result_time must be the fastest (lowest) value. Also I want to be able to choose if event_code should be “= 1” or “= 2”, since 100 and 200 meter resulttimes are mixed in the same table.

I asked a similiar question a few days ago, but without the event_code condition.

This is the answer we came up with.

select r.*
from result r
inner join (
    select athelete_id, min(result_time) as FastestTime
    from result
    group by athelete_id
) rm on r.athelete_id = rm.athelete_id and r.result_time = rm.FastestTime

Any ideas how I can add the event_code condition to this snippet?

  • 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-08T12:37:39+00:00Added an answer on June 8, 2026 at 12:37 pm

    Try this:

    select r.*
    from result r
    inner join (
        select athelete_id, min(result_time) as FastestTime
        from result
        where event_code = 1
        group by athelete_id
    ) rm on r.athelete_id = rm.athelete_id and r.result_time = rm.FastestTime
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with an advanced SQL-query (MSSQL 2000). I have a table called
need help/guide for sql select query, I have 2 table stock and stock_history, in
I need help with an SQL-Query. I have one table with many entries and
Need help with a query that I wrote: I have three tables Company id
I need some help with a T-SQL query. I want to count fields that
today i need your help to get an specific sql select query. i have
Need help on sql(mysql query) to check that the selected 'startdate' and 'enddate' does
I need help with building SQL query. I have 4 tables: Sellers, Goods, Projects
I need some advanced CSS help here. I have a login button and a
I have a very customized SQL query that I am having problems implementing. I

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.