From those two lists:
AVAILABLEDATES -date (DateTime) -maxBookings (Number) BOOKINGS -availableDate (Lookup to AVAILABLEDATES:Id) -User (Person)
I need to get all dates that their bookings don't reach maxBookings. In SQL it would be something like this:
SELECT ad.date FROM AvailableDates ad WHERE ad.maxBookings > (SELECT COUNT(*) FROM Bookings b WHERE b.availableDate = ad.Id)
How can I accomplish the same result via CAML-Query?