i have tblcontract with contractid
i have tblpaymentdue with pdid, pdcontract (referencing tblcontract), pdweek, pdamount,
I want to return the last entry in pdweek chronologically per contract.
So if there were 100 entries in tblcontract, and all of them had atleast one associated payment due, it would return 100 contractid's and its associated pdweek
kind of lost|||SELECT TBLCONTRACT.CONTRACTID, (SELECT MAX(PDWEEK) FROM TBLPAYMENTDUE WHERE TBLPAYMENTDUE.PDCONTRACT = TBLCONTRACT.CONTRACTID) AS LAST_CONTACT
FROM TBLCONTRACT
This will show each contractid and the highest value of pdweek in the tblpaymentdue table with their contractid, and null if there are no entries.
If you want to show just the contracts with contacts, add a where clause.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment