← Documentation

How to Read SQL

You don't need to write SQL to verify our results — just to recognize a handful of recurring patterns. This page walks through those patterns once, using one real query from a published report, so you can read any of our verification scripts afterward without treating them as a black box.

The patterns you'll see, over and over

Almost every query in this series is built from the same small set of pieces:

A real example, read line by line

This is Part 1 of the verification query behind Technical Report v1.16's Table 1 — finding blocks where a reconstruction's local variance coincidentally matches the ground truth's exactly, even though the two aren't required to match:

WITH candidates AS (
    SELECT sigma_gt
    FROM blocks
    WHERE sigma_gt > 1e-6 AND ssim_c_notta = 1.0
),
total AS (
    SELECT COUNT(*) AS n_total_blocks FROM blocks WHERE sigma_gt > 1e-6
)
SELECT 'n_found' AS metric, CAST(COUNT(*) AS VARCHAR) AS value FROM candidates
UNION ALL SELECT 'pct_of_blocks', CAST(ROUND(100.0*COUNT(*)/(SELECT n_total_blocks FROM total),4) AS VARCHAR) FROM candidates
UNION ALL SELECT 'max_sigma_gt', CAST(MAX(sigma_gt) AS VARCHAR) FROM candidates
UNION ALL SELECT 'min_sigma_gt', CAST(MIN(sigma_gt) AS VARCHAR) FROM candidates;

Reading it top to bottom:

That's the whole pattern. Most of our verification queries are longer only because they repeat this same shape — a WITH clause narrowing down to the rows that matter, followed by a handful of UNION ALL-ed summary rows — for more conditions or more models.

A few more patterns, for later reports

The reports from DOI 1.4 onward use a handful of additional pieces. Explained once here, so the per-report walkthroughs in SQL Reference can just point back to this page instead of re-explaining them every time.