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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:31:34+00:00 2026-06-09T16:31:34+00:00

This type of question is asked every now and then. The queries provided works,

  • 0

This type of question is asked every now and then. The queries provided works, but it affects performance.

I have tried the JOIN method:

SELECT * 
FROM nbk_tabl
INNER JOIN (
        SELECT ITEM_NO, MAX(REF_DATE) as LDATE
        FROM nbk_tabl 
        GROUP BY ITEM_NO) nbk2 
ON nbk_tabl.REF_DATE = nbk2.LDATE 
AND nbk_tabl.ITEM_NO = nbk2.ITEM_NO

And the tuple one (way slower):

SELECT * 
FROM nbk_tabl
WHERE REF_DATE IN (
                    SELECT MAX(REF_DATE) 
                    FROM nbk_tabl 
                    GROUP BY ITEM_NO
                  )

Is there any other performance friendly way of doing this?

EDIT: To be clear, I’m applying this to a table with thousands of rows.

  • 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-09T16:31:35+00:00Added an answer on June 9, 2026 at 4:31 pm

    Yes, there is a faster way.

    select *
    from nbk_table
    order by ref_date desc
    limit <n>
    

    Where is the number of rows that you want to return.

    Hold on. I see you are trying to do this for a particular item. You might try this:

    select *
    from nbk_table n
    where ref_date = (select max(ref_date) from nbk_table n2 where n.item_no = n2.item_no)
    

    It might optimize better than the “in” version.

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

Sidebar

Related Questions

I asked this question before but with less information than I have now. What
I am sure this type of question is asked every day, but I am
I know this type of question has been asked and answered before but I
I have seen many answers for this type of question but its not related
I already asked a question today : This one Now I have a code
I know this type of question has been asked a lot, but I really
I know this type of question has been asked a lot, but I haven't
It seems this type of question has been asked and answered a number of
Firstly, I know this [type of] question is frequently asked, so let me preface
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]

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.