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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:51:47+00:00 2026-06-15T01:51:47+00:00

I have a table storing transaction called TRANSFER . I needed to write a

  • 0

I have a table storing transaction called TRANSFER . I needed to write a query to return only the newest entry of transaction for the given stock tag (which is a unique key to identify the material) so i used the following query

SELECT a.TRANSFER_ID
     , a.TRANSFER_DATE
     , a.ASSET_CATEGORY_ID
     , a.ASSET_ID
     , a.TRANSFER_FROM_ID
     , a.TRANSFER_TO_ID
     , a.STOCK_TAG
 FROM TRANSFER a
INNER JOIN (
              SELECT STOCK_TAG
                   , MAX(TRANSFER_DATE) maxDATE
                FROM TRANSFER
               GROUP BY STOCK_TAG
            ) b
   ON a.STOCK_TAG = b.STOCK_TAG AND
      a.Transfer_Date =b.maxDATE

But i end with a problem where when more than one transfer happens on the same transfer date it returns all the row where as i need only the latest . how can i get the latest row?

edited:

transfer_id   transfer_date   asset_category_id  asset_id   stock_tag 
 1               24/12/2010      100               111         2000
 2               24/12/2011      100               111         2000
  • 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-15T01:51:49+00:00Added an answer on June 15, 2026 at 1:51 am

    To avoid the potential situation of rows not being inserted in transfer_date order, and maybe for performance reasons, you might like to try:

     select
       TRANSFER_ID      ,
       TRANSFER_DATE    ,
       ASSET_CATEGORY_ID,
       ASSET_ID         ,
       TRANSFER_FROM_ID ,
       TRANSFER_TO_ID   ,
       STOCK_TAG
     from (
       SELECT
         TRANSFER_ID      ,
         TRANSFER_DATE    ,
         ASSET_CATEGORY_ID,
         ASSET_ID         ,
         TRANSFER_FROM_ID ,
         TRANSFER_TO_ID   ,
         STOCK_TAG        ,
         row_number() over (
           partition by stock_tag
           order by     transfer_date desc,
                        transfer_id desc) rn
       FROM TRANSFER)
     where rn = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using mysql and have a table (Log_Table) storing user login dates, a
I have a table where I am storing configurations for a tool I have.
I have a table with column for storing product code. | product_id | Product-name
I have a simple MySQL table for storing notification in a web with social
I have a table which contains a column discussion_duration where I am storing certain
I have a customer table where I'm currently storing: Last Name First Name Middle
I have a MySQL table, in which I will be storing the email_id of
In a mysql MyISAM table, I have a column type mediumblob and storing captured
I have a table called Card that I am auditing with a shadow table
I am storing transactions in a table. These transactions have an ID which relates

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.