I have a table that records the firmware version for each device every day. If a device goes down, the script to populate the device's firmware won't be able to reach it for a value so there is no record for offline days. I need a view that will return the latest firmware version for each device every day, regardless if the device was down or not. This works great in Postgres SQL:
SELECT
d.ip,
d.date,
CASE
WHEN f.firmware_version IS NOT NULL THEN f.firmware_version
ELSE (--Use last available firmware_version for the device:
SELECT l.firmware_version
FROM firmware l
WHERE l.date < d.date AND l.firmware_version IS NOT NULL
ORDER BY l.date DESC
LIMIT 1)
END AS firmware_version
FROM
devices d --Table with a record for every device every day
LEFT JOIN firmware f ON d.date = f.date AND d.ip = f.ip
However, we are transitioning to Denodo, and I cannot get this query to work in Denodo. It seems to fail with the subquery in the case statement. Does anyone know how I can get logic like this to create a view in Denodo?