MySQL Forums
Forum List  »  Newbie

Re: Selecting distinct records
Posted by: David Fells
Date: April 06, 2005 09:18AM

SELECT
wb1.jobno, wb1.waybillno, wb1.dadd3, wb1.shipdate, wt1.status, wt1.dateAndTime
FROM waybill AS wb1, waytrack AS wt1
WHERE acctno = 'ROBIN'
AND wt1 = 'C'
AND wb1.jobno = wt1.jobno
AND wt1.dateAndTime= (
SELECT MAX(dateAndTime)
FROM waytrack AS wt2
WHERE
wt2.jobno = wt1.jobno
GROUP BY
wt2.jobno
)
ORDER BY wb1.shipdate DESC

If I understood your question and your data, you want to select the most recent tracking record for each bill, right?

Never store date and time seperately, use a single DATETIME column.

Options: ReplyQuote


Subject
Written By
Posted
April 06, 2005 09:07AM
Re: Selecting distinct records
April 06, 2005 09:18AM
April 06, 2005 02:15PM
April 06, 2005 02:43PM
April 06, 2005 03:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.