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 86k
  • Answers 86k
  • 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
  • Editorial Team
    Editorial Team added an answer As far as I am aware there is no way… May 11, 2026 at 5:19 pm
  • Editorial Team
    Editorial Team added an answer Your question is based on a faulty assumption. It's perfectly… May 11, 2026 at 5:19 pm
  • Editorial Team
    Editorial Team added an answer For performance reasons, don't point a web site to a… May 11, 2026 at 5:19 pm

Related Questions

This question is complicated so examples would work best...I have the following table on
What are the best tools/programming-techniques for following a complicated nesting of symlinks and completely
I'm joining a couple of tables, and aggregating some of the columns via GROUP
I have a somewhat complicated branching structure at work (at least for me). It
I have some unicode text that I want to clean up using regular expressions.

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.