Pooja Chavan
1 min readFeb 2, 2024

--

Anatomy/Parts of a SQL Statement

SQL is the standard language for talking with RDBMS. Extensively used in all data-related roles and with English-like syntax, beginner SQL is fairly easy to learn.

SQL query consists of keywords, clauses, functions and the entire statement itself.

🔷 Keywords: are individual SQL elements, these are reserved words in SQL and are used to direct the database to perform various actions.
Examples:
💥FROM
💥SELECT
💥WHERE
💥ON
💥OR
💥ORDER BY
💥LIMIT

🔷 Clause: is a part of a SQL statement, that lets you filter (how you want your data to be queried/updated/deleted/inserted) or customize (how you want your data to be displayed).
Examples:
💥WHERE id=20
💥AND city_id=2
💥OR last_name like ‘ Ho%’
💥GROUP BY dept_id
💥ORDER BY last_name desc

Note the subtle difference between keyword and clause.

🔷 Function: are methods/sub-programs used to perform data operations, SQL has a rich library of scalar, aggregate, statistical and window functions.
Examples:
💥COUNT (dep_id)
💥AVG(sales)
💥LOWER(last_name)

🔷 Statement: any text that the database engine recognizes as a valid command.
Examples:
💥SELECT avg(sales)
from store_data
💥UPDATE employees
set dep_name=”IT’
where dep_id=30

🔷Query: is a SQL statement that returns a record set (can be possibly empty). Once a statement is executed, it becomes a query.

Query/Statement are often used interchangeably.

The examples listed are not exhaustive.

--

--

Pooja Chavan

Data Cleaning/Wrangling/Visualization | Excel | SQL |Tableau