SELECT
rates_Calendar.date,
subQuery.name,
COALESCE(subQuery.amount,0) as amount,
subQuery.reference,
subQuery.property
FROM
rates_Calendar
LEFT JOIN (
SELECT
rates_Booking.date,
unit.unit,
unit.abbreviation as name,
rates_Booking.amount,
rates_Booking.bookingReference AS reference,
property.property
FROM
rates_Booking
LEFT JOIN booking ON booking.reference = rates_Booking.bookingReference
LEFT JOIN unit ON booking.apartment = unit.unit
LEFT JOIN property ON property.property = unit.property
# unit to apartments
LEFT JOIN apartments ON (apartments.unit = unit.unit)
LEFT JOIN apartmentTypes ON (apartmentTypes.id = apartments.apartmentTypeId)
WHERE
rates_Booking.date BETWEEN @startDate AND @endDate
AND unit.unit = 221
GROUP BY
property.area,
property.property,
apartmentTypes.id,
unit.unit,
rates_Booking.date
) AS subQuery ON subQuery.date = rates_Calendar.date
WHERE
rates_Calendar.date BETWEEN @startDate AND @endDate
GROUP BY
subQuery.reference,
subQuery.unit,
subQuery.apartmentTypeId,
subQuery.property,
subQuery.area,
rates_Calendar.date
Теперь очевидно, что этот запрос приведет к NULLS для дат, которые не совпадают. Есть ли способ обновить все NULLS значениями NON NULL?
2013-01-01 unitA 138 1 property1
2013-01-02 unitA 138 1 property1
2013-01-03 unitA 138 1 property1
2013-01-04 NULL 0 NULL NULL
2013-01-05 NULL 0 NULL NULL
Есть ли способ обновить NULL с NON NULLS в соответствующих столбцах?
Я пытаюсь это сделать, потому что скрытие групп строк с NULLS невозможно, как можно понять из ссылки: Скрыть группы строк NULL в JasperReports