mercredi 18 juillet 2018

Laravel groupby id get newest records

I have :

ID | BRAND_ID | CUSTID | EXPIRY_DATE | CREATED_DATE
1        1        22     2018-02-02    2018-01-01 00:00:00
2        1        22     2018-02-02    2018-02-02 00:00:00
3        1        22     2019-02-02    2018-02-02 00:05:00
4        1        22     2019-02-02    2018-02-02 00:05:00
5        1        22     2018-02-02    2018-02-02 00:07:00
6       1        22     2018-02-02    2018-02-02 00:07:00

trying to get the last newest records grouping by custid

->groupBy('CUST_ID')
->ordrBy('CREATED_DATE', 'desc')

but i'm getting the first 2 rows when i add groupBy, not getting the last 2



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire