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

  • Home
  • SEARCH
  • 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 145997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:31:22+00:00 2026-05-11T08:31:22+00:00

This question is complicated so examples would work best…I have the following table on

  • 0

This question is complicated so examples would work best…I have the following table on ODBC, not SQL server Management

NAME     SEQNUM       JOHN     2           JOHN     4 JOHN     7 MARY     12 MIKE     4 MIKE     9 PETER    7 PETER    12 

So, i want to pull back one name with the lowest seqNum…

NAME     SEQNUM JOHN     2 MARY     12 MIKE     4 PETER    7 

This data will not work with SELECT (MIN(SEQNUM)). That returns a number. I want the actual data to put in my dataset. Does ANYONE know how to do that?

  • 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. 2026-05-11T08:31:23+00:00Added an answer on May 11, 2026 at 8:31 am
    SELECT t1.* FROM yourtable t1  LEFT OUTER JOIN yourtable t2   ON (t1.name = t2.name AND t1.seqnum > t2.seqnum) WHERE t2.seqnum IS NULL; 

    Re. Dems’ comment:

    If you simply use GROUP BY name then your select-list can only include name and the aggregate function MIN(). It’s often the case that you really want the whole row where the minimum value occurs per group.

    If you use the TOP solution (or LIMIT if you use MySQL, PostgreSQL, SQLite), then you can’t get the minimum for multiple groups based on name, you can only get the minimum for one name.

    I read between the lines of the OP’s question and guessed that they want the whole row, that there are more columns than those shown in the question (there always are), and that the desired query should return results for multiple names, not just one.


    Re. SquareCog’s comment:

    The solution you suggest is also a join:

    SELECT t1.* FROM yourtable t1   JOIN (SELECT name, MIN(seqnum) AS seqnum FROM yourtable GROUP BY name) t2   USING (name, seqnum); 

    However, this solution probably can’t use indexes to evaluate the join, whereas the solution I gave can.

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer To solve this, I ended up using the TupleToPropertyResultTransformer and… May 11, 2026 at 9:47 am
  • added an answer find_showtimes is not a built-in finder - if it were,… May 11, 2026 at 9:47 am
  • added an answer The problem is that your use of let is wrong.… May 11, 2026 at 9:47 am

Related Questions

Before you answer, this question is complicated: We are developing in asp.net / asp.net
This is a very complicated question concerning how to serialize data via a web
This question is kind of an add-on to this question In C#, a switch
This question is a follow up to my previous question about getting the HTML
(This question is over 6 years old and probably no longer has any relevance.)
This question is about removing sequences from an array, not duplicates in the strict
This question is the other side of the question asking, How do I calculate
This question is about organizing the actual CSS directives themselves within a .css file.
This question is related to (but perhaps not quite the same as): Does Django
This question is overflow from the following question: How do I programmatically convert mp3

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.