Write a SQL query using complex joins to retrieve the latest status update for each device in an IoT application database.