Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Tuesday, July 30, 2024

Group By and Max(Date) in SQL / disticnt (GROUP BY with MAX(DATE) [duplicate] )

 Hi,


Train    Dest      Time

1        HK        10:00

1        SH        12:00

1        SZ        14:00

2        HK        13:00

2        SH        09:00

2        SZ        07:00


Expected output

Train    Dest     Time

1            SZ      14:00 

2           HK      13:00


Distinct ( max(AccountingDate) and group by (SubLedgerVoucherDataAreaID) from GeneralJournalEntry )

 distinct (GROUP BY with MAX(DATE) [duplicate] )

/**************************/

SELECT GJE.SubLedgerVoucherDataAreaID, MAX(GJE.AccountingDate) as MaxDate

FROM GENERALJOURNALENTRY GJE

GROUP BY GJE.SubLedgerVoucherDataAreaID


Thanks,


No comments:

Post a Comment

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...