Как я могу получить последние записи, основываясь только на invcreated
How do I get the latest record only based on the invcreated. there are more than 1lak records and same jobno having more than 100 records. In an example, I am taken only one jobno
Теперь запрос возвращает
JobOrderID JobNo INVInvoiceid INVInvoiceNo INVStatusID INVInvoiceModeID INVCreateddate -------------------- ------------------------- -------------------- -------------------- ----------- ---------------- ----------------------- 2802 13011900263 43877 INF220519025921 7 2 2019-05-22 15:16:00.000 2802 13011900263 43881 NULL 1 2 2019-05-22 16:29:00.000
Но Мне Нужно ...
JobOrderID JobNo INVInvoiceid INVInvoiceNo INVStatusID INVInvoiceModeID INVCreateddate -------------------- ------------------------- -------------------- -------------------- ----------- ---------------- ----------------------- 2802 13011900263 43881 NULL 1 2 2019-05-22 16:29:00.000
Что я уже пробовал:
select J.JobOrderID,J.JobNo, INV.InvoiceID as INVInvoiceid,INV.InvoiceNo as INVInvoiceNo,INV.StatusID as INVStatusID,INV.InvoiceModeID as INVInvoiceModeID, INV.Createddate as INVCreateddate from ffs_tbl_joborder J inner join FFS_Tbl_AirJob AJ on AJ.AirJobID=J.JobOrderID and AJ.JobNo=J.JobNo left join FFS_TBl_Invoice INV on INV.JobOrderID=J.JobOrderID and INV.JobNo=J.JobNo and INV.JobType=J.JobType where J.jobno='13011900263' and INV.JobType='AirJob' group by J.JobOrderID,J.JobType,J.JobNo,J.Status,AJ.Status,INV.InvoiceID,INV.InvoiceNo,INV.StatusID,INV.InvoiceModeID,INV.Createddate