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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:23:09+00:00 2026-06-03T09:23:09+00:00

I sort the rows on date. If I want to select every row that

  • 0

I sort the rows on date. If I want to select every row that has a unique value in the last column, can I do this with sql?

So I would like to select the first row, second one, third one not, fourth one I do want to select, and so on.

enter image description here

  • 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-03T09:23:11+00:00Added an answer on June 3, 2026 at 9:23 am

    What you want are not unique rows, but rather one per group. This can be done by taking the MIN(pk_artikel_Id) and GROUP BY fk_artikel_bron. This method uses an IN subquery to get the first pk_artikel_id and its associated fk_artikel_bron for each unique fk_artikel_bron and then uses that to get the remaining columns in the outer query.

    SELECT * FROM tbl 
    WHERE pk_artikel_id IN
      (SELECT MIN(pk_artikel_id) AS id FROM tbl GROUP BY fk_artikel_bron)
    

    Although MySQL would permit you to add the rest of the columns in the SELECT list initially, avoiding the IN subquery, that isn’t really portable to other RDBMS systems. This method is a little more generic.

    It can also be done with a JOIN against the subquery, which may or may not be faster. Hard to say without benchmarking it.

    SELECT * 
    FROM  tbl
      JOIN (
        SELECT 
          fk_artikel_bron, 
          MIN(pk_artikel_id) AS id
        FROM tbl
        GROUP BY fk_artikel_bron) mins ON tbl.pk_artikel_id = mins.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to sort a DataTable based on a column which has date value.
I want to sort on a certain column only for rows containing a certain
Can any one help me how to sort rows by relevance for the following
...@Sort bit) AS SELECT .............. and I want to Order only if Sort =
Sort of a methods/best practices question here that I am sure has been addressed,
I have a table with a row that looks like this: ( 20091231 48498429,
I have a query something like this: SELECT title, desc, date FROM tablename ORDER
I sort of understand this, at least the function of generators (I've used them
How can I can sort based on a key word? I have a kind-of
I sort the records of the datatable datewise with the column TradingDate which is

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.