所以我有以下查询..
select rooms.id room_id, rooms.cnt, booked_dates.cnt, sum(booked_dates.cnt)
from rooms
LEFT JOIN booked_dates
on rooms.id = booked_dates.rid and
(booked_dates.start between '2013-05-06' and '2013-05-09')
where rooms.ht = 4 and rooms.id = 138
group by booked_dates.start
它返回以下结果..
现在我需要按 对结果进行分组room_id
并获取列max
中的数字sum(booked_dates.cnt)
。因此,对于示例,它将是:
138 | 20 | 4 | 12
我该怎么做?谢谢。