Exercise · SQL & Querying
Predict, then run it
Predict the output
'Latest reading per sensor' via ROW_NUMBER, with two rows sharing taken_at:
SELECT COUNT(*) FROM (SELECT sensor, ROW_NUMBER() OVER (PARTITION BY sensor ORDER BY taken_at DESC) rn FROM readings) t WHERE rn=1;
There are 2 sensors. Predict the exact output (rn=1 count).