I have a table users and degrees which is joined with users_degrees.
a degree has a level. I need the highest degree per user. How do i do this best/easiest with CakePHP3 ?
SELECT user_id, level, degree_name from users_degrees ud LEFT JOIN degrees d on ud.degree_id = d.id group by applicant_id, degree_id, level, en;
This query will get me the results, still not only the max.
user_id level degree_name 1 1 degree_1 1 3 degree_3 1 4 degree_4 2 3 degree_3 2 4 degree_4 3 1 degree_1 3 4 degree_4
i think i need to have max(level) somewhere, but can’t figure out where, and how it would translate to Cake.