﻿SELECT MACHINE_VERSIONS.NAME MACHINE_TYPE, SERIAL_NUMBER, MACHINES.NAME NAME, ORGANIZATIONS.NAME ORGANIZATION, SITES.NAME SITE, UPDATED_ON, APPLICATION_VERSION, FIRMWARE_VERSION, VERSION_TAG FROM (SELECT MACHINE_GUID, MAX(LAST_UPDATED) UPDATED_ON FROM TANGO_UPDATES GROUP BY MACHINE_GUID) LAST_UPDATES
INNER JOIN MACHINES ON MACHINES.GUID = LAST_UPDATES.MACHINE_GUID
INNER JOIN TANGO_UPDATES ON TANGO_UPDATES.LAST_UPDATED = LAST_UPDATES.UPDATED_ON
INNER JOIN ORGANIZATIONS ON ORGANIZATIONS.GUID = MACHINES.ORGANIZATION_GUID
INNER JOIN MACHINE_VERSIONS ON MACHINE_VERSIONS.GUID = MACHINES.MACHINE_VERSION_GUID
LEFT JOIN SITES ON SITES.GUID = MACHINES.SITE_GUID ORDER BY APPLICATION_VERSION DESC 