Tables, Rows, and Columns in SQL
Tables organize data into columns, and each row is one record.
A table has a name, like
customers. Columns describe the fields available in that table, like
first_name
or
state.
Rows are the records inside the table. In the Garden Shop dataset, each row
in
customers
represents one customer.
Read a table before querying it
Before writing a report query, inspect the table name, the column names, and a few sample rows. That quick scan tells you what each row represents, which columns are identifiers, and which columns are useful for filtering, sorting, or grouping.
select count(*) as row_count
from table_name Schema · Garden Shop Table · customers 9 columns · 20 rows
One row per customer. Some customers have no phone on file.
Count how many rows are in the customers table. Name the output column customer_count.
Run your query to inspect the result.
Expected answer
- Columns: customer_count.
- Rows: 1 summary row.
- The customer_count value should be 20.
Related
Clause order and the shape of a SELECT query.
SELECT, WHERE, ORDER BY, and LIMIT at a glance.
WHERE is evaluated before SELECT aliases exist.
The parser stopped at the first word it could not use.
No table in the FROM clause has that column.
Understand tables, rows, columns, and queries.