List satellite images with valid coordinates joined to their sensors, newest first

Quick Overview

Write a SQL query that joins satellite image metadata to sensor details, keeps only images with valid latitude and longitude, and returns the newest captures first. It tests inclusive range filters, how NULL values behave in a WHERE clause, and deterministic ordering with a unique tiebreaker.

List satellite images with valid coordinates joined to their sensors, newest first

Company: Intel

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

An imagery pipeline writes one metadata row per captured satellite image to `satellite_images`, and each row references the sensor that captured it in `sensors`. Coordinates are stored as received from upstream and are not validated on write, so some rows carry impossible or missing values. Return each image with valid coordinates (`latitude` between -90 and 90, `longitude` between -180 and 180) joined with its sensor, as `image_id`, `image_name`, `sensor_name`, `sensor_type`, `latitude`, `longitude`, `capture_time`, `resolution_meters`, `cloud_cover_pct`, `file_size_mb`. Order by `capture_time` descending, then `image_id` ascending. ```hint Edge rows Before writing the filter and the sort, decide what should happen to an image that sits exactly on a coordinate limit, one with a missing coordinate, and two images captured at the same moment. ``` ### Input Table(s) `sensors` (primary key `sensor_id`) | Column | Type | Meaning | |---|---|---| | sensor_id | INT | Sensor identifier | | sensor_name | VARCHAR | Sensor name | | sensor_type | VARCHAR | Kind of sensor, for example 'optical', 'radar' or 'thermal' | `satellite_images` (primary key `image_id`) | Column | Type | Meaning | |---|---|---| | image_id | INT | Image identifier | | image_name | VARCHAR | Image name | | sensor_id | INT | Sensor that captured the image; references `sensors.sensor_id` | | latitude | DECIMAL(9,6) | Latitude of the image center in degrees; may be out of range or NULL | | longitude | DECIMAL(9,6) | Longitude of the image center in degrees; may be out of range or NULL | | capture_time | TIMESTAMP | When the image was captured | | resolution_meters | DECIMAL(8,2) | Ground resolution in meters per pixel | | cloud_cover_pct | DECIMAL(5,2) | Share of the image covered by cloud, in percent | | file_size_mb | DECIMAL(10,2) | File size in megabytes | ### Output Contract - One row per image with valid coordinates, with these columns in this order: `image_id`, `image_name`, `sensor_name`, `sensor_type`, `latitude`, `longitude`, `capture_time`, `resolution_meters`, `cloud_cover_pct`, `file_size_mb`. - Order by `capture_time` descending, then `image_id` ascending. `image_id` is unique, so the order is fully determined. - Return values as stored, with no rounding or reformatting. ### Example `sensors` | sensor_id | sensor_name | sensor_type | |---|---|---| | 1 | OPT-A | optical | | 2 | SAR-B | radar | | 3 | IR-C | thermal | `satellite_images` | image_id | image_name | sensor_id | latitude | longitude | capture_time | resolution_meters | cloud_cover_pct | file_size_mb | |---|---|---|---|---|---|---|---|---| | 1001 | coast_0412 | 1 | 37.774900 | -122.419400 | 2024-04-12 10:15:00 | 0.50 | 12.30 | 845.20 | | 1002 | delta_0412 | 2 | 23.810300 | 90.412500 | 2024-04-12 10:15:00 | 3.00 | 0.00 | 1210.75 | | 1003 | glitch_0413 | 1 | 95.000000 | 10.000000 | 2024-04-13 08:00:00 | 0.50 | 40.00 | 790.00 | | 1004 | pole_0413 | 3 | 90.000000 | 0.000000 | 2024-04-13 06:30:00 | 10.00 | 85.50 | 300.40 | | 1005 | dateline_0411 | 2 | -16.500000 | -180.000000 | 2024-04-11 22:45:00 | 3.00 | 5.25 | 1100.00 | | 1006 | badlon_0414 | 3 | 10.000000 | 181.500000 | 2024-04-14 09:00:00 | 10.00 | 20.00 | 310.00 | | 1007 | nolon_0412 | 1 | 45.000000 | NULL | 2024-04-12 11:00:00 | 0.50 | 3.00 | 820.00 | Expected output: | image_id | image_name | sensor_name | sensor_type | latitude | longitude | capture_time | resolution_meters | cloud_cover_pct | file_size_mb | |---|---|---|---|---|---|---|---|---|---| | 1004 | pole_0413 | IR-C | thermal | 90.000000 | 0.000000 | 2024-04-13 06:30:00 | 10.00 | 85.50 | 300.40 | | 1001 | coast_0412 | OPT-A | optical | 37.774900 | -122.419400 | 2024-04-12 10:15:00 | 0.50 | 12.30 | 845.20 | | 1002 | delta_0412 | SAR-B | radar | 23.810300 | 90.412500 | 2024-04-12 10:15:00 | 3.00 | 0.00 | 1210.75 | | 1005 | dateline_0411 | SAR-B | radar | -16.500000 | -180.000000 | 2024-04-11 22:45:00 | 3.00 | 5.25 | 1100.00 | Image 1003 has a latitude of 95 and image 1006 a longitude of 181.5, so both are dropped, and image 1007 is dropped because its longitude is missing. Images 1004 and 1005 sit exactly on a limit and are kept. Images 1001 and 1002 share a capture time, so the smaller `image_id` comes first. ### Constraints and Clarifications - `sensors` has at most 100 rows and `satellite_images` at most 10,000 rows. - Valid coordinates are `latitude` in [-90, 90] and `longitude` in [-180, 180], limits included. Stored values can fall outside these ranges or be NULL, and such images are excluded. - `cloud_cover_pct` is 0.00 to 100.00 and `resolution_meters` is positive. - Every `sensor_id` in `satellite_images` references a valid sensor. - `capture_time` is never NULL, and several images can share the same `capture_time`.

Overview: Write a SQL query that joins satellite image metadata to sensor details, keeps only images with valid latitude and longitude, and returns the newest captures first. It tests inclusive range filters, how NULL values behave in a WHERE clause, and deterministic ordering with a unique tiebreaker.

Intel logo
Intel
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

An imagery pipeline writes one metadata row per captured satellite image to satellite_images, and each row references the sensor that captured it in sensors. Coordinates are stored as received from upstream and are not validated on write, so some rows carry impossible or missing values.

Return each image with valid coordinates (latitude between -90 and 90, longitude between -180 and 180) joined with its sensor, as image_id, image_name, sensor_name, sensor_type, latitude, longitude, capture_time, resolution_meters, cloud_cover_pct, file_size_mb. Order by capture_time descending, then image_id ascending.

Input Table(s)

sensors (primary key sensor_id)

ColumnTypeMeaning
sensor_idINTSensor identifier
sensor_nameVARCHARSensor name
sensor_typeVARCHARKind of sensor, for example 'optical', 'radar' or 'thermal'

satellite_images (primary key image_id)

ColumnTypeMeaning
image_idINTImage identifier
image_nameVARCHARImage name
sensor_idINTSensor that captured the image; references sensors.sensor_id
latitudeDECIMAL(9,6)Latitude of the image center in degrees; may be out of range or NULL
longitudeDECIMAL(9,6)Longitude of the image center in degrees; may be out of range or NULL
capture_timeTIMESTAMPWhen the image was captured
resolution_metersDECIMAL(8,2)Ground resolution in meters per pixel
cloud_cover_pctDECIMAL(5,2)Share of the image covered by cloud, in percent
file_size_mbDECIMAL(10,2)File size in megabytes

Output Contract

  • One row per image with valid coordinates, with these columns in this order: image_id , image_name , sensor_name , sensor_type , latitude , longitude , capture_time , resolution_meters , cloud_cover_pct , file_size_mb .
  • Order by capture_time descending, then image_id ascending. image_id is unique, so the order is fully determined.
  • Return values as stored, with no rounding or reformatting.

Example

sensors

sensor_idsensor_namesensor_type
1OPT-Aoptical
2SAR-Bradar
3IR-Cthermal

satellite_images

image_idimage_namesensor_idlatitudelongitudecapture_timeresolution_meterscloud_cover_pctfile_size_mb
1001coast_0412137.774900-122.4194002024-04-12 10:15:000.5012.30845.20
1002delta_0412223.81030090.4125002024-04-12 10:15:003.000.001210.75
1003glitch_0413195.00000010.0000002024-04-13 08:00:000.5040.00790.00
1004pole_0413390.0000000.0000002024-04-13 06:30:0010.0085.50300.40
1005dateline_04112-16.500000-180.0000002024-04-11 22:45:003.005.251100.00
1006badlon_0414310.000000181.5000002024-04-14 09:00:0010.0020.00310.00
1007nolon_0412145.000000NULL2024-04-12 11:00:000.503.00820.00

Expected output:

image_idimage_namesensor_namesensor_typelatitudelongitudecapture_timeresolution_meterscloud_cover_pctfile_size_mb
1004pole_0413IR-Cthermal90.0000000.0000002024-04-13 06:30:0010.0085.50300.40
1001coast_0412OPT-Aoptical37.774900-122.4194002024-04-12 10:15:000.5012.30845.20
1002delta_0412SAR-Bradar23.81030090.4125002024-04-12 10:15:003.000.001210.75
1005dateline_0411SAR-Bradar-16.500000-180.0000002024-04-11 22:45:003.005.251100.00

Image 1003 has a latitude of 95 and image 1006 a longitude of 181.5, so both are dropped, and image 1007 is dropped because its longitude is missing. Images 1004 and 1005 sit exactly on a limit and are kept. Images 1001 and 1002 share a capture time, so the smaller image_id comes first.

Constraints and Clarifications

  • sensors has at most 100 rows and satellite_images at most 10,000 rows.
  • Valid coordinates are latitude in [-90, 90] and longitude in [-180, 180], limits included. Stored values can fall outside these ranges or be NULL, and such images are excluded.
  • cloud_cover_pct is 0.00 to 100.00 and resolution_meters is positive.
  • Every sensor_id in satellite_images references a valid sensor.
  • capture_time is never NULL, and several images can share the same capture_time .