AnalystPath

Resolve Sensor Threshold Checks

SQLMediumMid level~15 min

Problem

A monitoring system stores named numeric readings and a list of comparison checks between two of those readings.

Table: `Gauges`

```text
+--------+---------+
| Column | Type |
+--------+---------+
| tag | varchar |
| reading| int |
+--------+---------+
tag is the primary key (a short label, up to 3 characters).
reading is the current numeric value of that gauge.
```

Table: `Checks`

```text
+-----------+---------+
| Column | Type |
+-----------+---------+
| lhs | varchar |
| comparator| varchar |
| rhs | varchar |
+-----------+---------+
lhs and rhs are gauge tags. comparator is one of '>', '<', or '='.
Each row asks whether the comparison lhs comparator rhs holds.
```

For every check, return its three columns plus a `verdict` column equal to the string `pass` when the comparison is true and `fail` otherwise.

Tables

Example rows — the live problem includes the full dataset.

Gauges
tagreading
aa66
bb77
Checks
lhscomparatorrhs
aa>bb
aa<bb
aa=bb

Expected output

Your answer should return 6 rows with the columns lhs, comparator, rhs, verdict.

Starter code (SQL)

SELECT *
FROM Gauges;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions