Ono
1
All, please I need help with showing output of just 1 row of most recent Previous Date, New Date and Change Date.
This is based on the most recent CHANGE DATE(02/01/2025)
Output should be 03/05 2025 for Previous Date and 03/26/2026 for New Date.
All, please I need help with outputting only the most recent date. This will be based on the Most recent Change date
hi
hope this helps
create tables sample data script
CREATE TABLE IF NOT EXISTS OrderChanges (
OrderNumber INT,
ChangeDate DATE,
PreviousDate DATE,
NewDate DATE,
ChangeNumber INT
);
-- Insert sample data
INSERT INTO OrderChanges (OrderNumber, ChangeDate, PreviousDate, NewDate, ChangeNumber) VALUES
(43246, '2025-01-20', '2024-05-08', '2025-04-02', 6126),
(43246, '2025-02-01', '2025-03-05', '2026-03-26', 6123),
(43246, '2025-01-10', '2024-08-05', '2025-06-01', 5783);
CREATE INDEX idx_ChangeDate ON OrderChanges (ChangeDate);
SELECT TOP 1
PreviousDate,
NewDate,
ChangeDate
FROM
YourTableName
ORDER BY
ChangeDate DESC;