Field Selection

  • Thread starter Thread starter David
  • Start date Start date
D

David

In a query I want to only return fields that are not null
from the table.
That is, query on a "key field" and if another field is
null not return that field.
Time Sensor 1 Sensor2
1 1500
2 1500
If I query on time1 only sensor1 field would return
If I query on time2 only sensor2 field would return.
David
 
In a query I want to only return fields that are not null
from the table.
That is, query on a "key field" and if another field is
null not return that field.
Time Sensor 1 Sensor2
1 1500
2 1500
If I query on time1 only sensor1 field would return
If I query on time2 only sensor2 field would return.
David

What if there is data on both Sensor fields? This table is not
normalized, which is why you're having difficulty! A better table
structure would be

Time SensorNo SensorValue
1 1 1500
2 2 1500

With your current table structure, you'll need a complex expression:

IIF(IsNull([Sensor 1]), IIF(IsNull([Sensor 2]), NULL, [Sensor 2]),
[Sensor 1])
 
Back
Top