I am new to databases and I was given a task at work to improve an open source system that's been designed by someone else.
What I tried so far is:
select r.id, r.room_name, e.type,max(e.start_time) as st, max(e.end_time) as et ,max(e.timestamp) as updt
from mrbs_room r
join mrbs_entry e on r.id=e.room_id
where r.area_id=1 and r.disabled=0
group by r.id
order by r.room_name DESC;
Snapshot of result:
The last field (Name) records results are not matching the database records.
What am I doing wrong?