A SELECT COUNT(*) statement returns the number of rows in a table or other selected relation. Use it during initial data surveying to test whether a dataset contains the expected volume before deeper analysis. section 5.2.2
Checking smart-building sensor coverage
Counting temperature_readings returns 262,944,000 rows. Five years includes one leap year: 5 × 365 + 1 = 1,826 days, and 262,944,000 ÷ 1,826 = 144,000 readings per day. The round result suggests roughly 100 sensors reported every minute, while also flagging an assumption worth checking. section 5.2.2
select count(*) from temperature_readings >262944000
Inspect the query and returned row count used to establish whether the temperature table contains approximately the expected data volume. section 5.2.2
Use the count as a checkpoint, then reduce uncertainty with targeted inspection:
- Compare the result with expected dates, reporting frequency, and sensor coverage. section 5.2.2
- Sample a few rows with SELECT * and LIMIT, probe years with WHERE, and record unexplained fields as backlog investigations. section 5.2.2
