-- NULL integrity check across telemetry tables
SELECT
    'position_history.imei_null'      AS check_field,
    COUNT(*)                          AS null_count
FROM tracksolid.position_history
WHERE imei IS NULL
UNION ALL
SELECT
    'position_history.gps_time_null',
    COUNT(*)
FROM tracksolid.position_history
WHERE gps_time IS NULL
UNION ALL
SELECT
    'alarms.imei_null',
    COUNT(*)
FROM tracksolid.alarms
WHERE imei IS NULL
UNION ALL
SELECT
    'alarms.alarm_type_null',
    COUNT(*)
FROM tracksolid.alarms
WHERE alarm_type IS NULL
UNION ALL
SELECT
    'obd_readings.imei_null',
    COUNT(*)
FROM tracksolid.obd_readings
WHERE imei IS NULL;
