mercredi 30 janvier 2019

Laravel Query to get distinct values on a column, but after using orderby to get latest distinct values

I want to show only distinct rows from a table, but those values needs to be the latest ones, which I am filtering from date in the table. Here is my query. the result I am getting is the older row from date, the orderby is not working here I guess. please help. I have attached my table.

$reports= DB::table('resident_assessment')->where('resident_assessment.assessment_date','<=',$date)->join('assessment_entry','resident_assessment.assessment_id','=','assessment_entry.assessment_id')->orderby('resident_assessment.assessment_date','desc')->distinct()->get();

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire