Nested Query for empty measurement's values returned from first query



I am trying to create a nested query which will return data for given measurements. If first or outer query’s result does not have any data for some of the measurements then second query will return data for only those measurements.
Any idea how to write it?