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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:36:53+00:00 2026-06-13T07:36:53+00:00

I am attempting to write a query that pulls Order information from various tables.

  • 0

I am attempting to write a query that pulls Order information from various tables. I have hit a road block at the target date value.

It seems that every time a target date is changed a new row is added in that table. All I want is to be able to select only the newest Target Date. What should I do?

 select Distinct
 OR01001 AS OrderNumber,
 OR01002 AS OrderType,
 OR01003 AS CustomerCode,
 OR01015 AS OrderDate,
 OR01017 AS CustomerREP,
 OR01018 AS ContactPerson,
 OR01019 AS SalesmanNumber,
 OR03011 - OR03012 AS OpenQuantity,
 SC03003 AS StockBalance,
 OR01050 AS WarehouseNumber,
 OR01072 AS CustomerPO,
 OR03005 AS ItemCode,
 OR03002 AS LineNumber,
 OR500100.OR50004 As TargetDate
 from OR010100
 INNER Join OR030100 ON OR030100.OR03001 = OR010100.OR01001
 INNER Join SL010100 ON SL010100.SL01001 = OR010100.OR01003
 INNER Join SC030100 ON SC030100.SC03001 = OR030100.OR03005 
 Inner JOIN OR500100 ON OR500100.OR50001 = OR010100.OR01001 
 where OR010100.OR01002 <> 0 AND OR010100.OR01002 <> 6 AND OR01017 = 'SLOTT' 
 Order by OR01017 ASC;
  • 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-13T07:36:54+00:00Added an answer on June 13, 2026 at 7:36 am

    If I understand your columns correctly, here’s one way:

    SELECT ...,
        OR500100A.OR50004 AS TargetDate
    FROM ...
    INNER JOIN OR500100 AS OR500100A ON OR500100A.OR50001 = OR010100.OR01001 
        AND NOT EXISTS(SELECT 1 FROM OR500100 AS OR500100B 
                       WHERE OR500100B.OR5001 = OR010100.OR01001 
                       AND OR500100B.OR50004 > OR500100A.OR50004)
    ...
    

    This makes sure you only get one OR500100 row with the latest value in OR50004 for the given OR5001.

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

Sidebar

Related Questions

I have been attempting to write a VBA Script that can parse out other
I apologize for the vague title. I am attempting to write a query that
I am attempting to write the results from an SQL query into text files.
This is driving me nuts. I have two tables that I am attempting to
We have a query we're attempting to write for paging, where we want to
I'm attempting to write a query that will allow me to get any record
I'm attempting to write a query that will return The most recent AccountDate with
I'm attempting to write a query that will return any customer that has multiple
I'm completely new to MySQL. I'm attempting to write a query that inserts a
have an issue with a fairly basic query I'm attempting to write. select count

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.