Skip to content
Advertisement

MySQL get latest 7 days reservations, grouped by NameResource

I’m tring to write a query, without a good resultset.
I would to retreive a Number of reservations in last 7 days.
Grouped by NameOfResource.
When i’m tring to set a WHERE clause like this prenotazioni.Data >= CURDATE() - INTERVAL 7 DAY
I get only NameOfResource with reservations in latest 7 days, but not the rooms without reservations.

My Query was like that: (without WHERE the result is good)

Thank you to explain me where I was wrong.

Advertisement

Answer

You can use a LEFT JOIN, if you want all rooms, even those with a count of 0:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement