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。有没有办法用 NON NULL 值更新所有 NULLS?
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
有没有办法用相应列中的 NON NULLS 更新 NULL?
我正在为此尝试,因为无法从链接中理解使用 NULLS 隐藏 rowGroups: Hide NULL Row Groups JasperReports