Chapter 7. Operators and Functions
Operators and functions are used to perform calculations, comparisons, and transformations within a SQL statement. This chapter provides code examples for commonly used operators and functions.
The following query highlights five operators (+, =, OR, BETWEEN, AND) and two functions (UPPER, YEAR):
-- Pay increases for employees
SELECT name, pay_rate + 5 AS new_pay_rate
FROM employees
WHERE UPPER(title) = 'ANALYST'
OR YEAR(start_date) BETWEEN 2016 AND 2018;
In addition to SELECT statements, operators and functions can also be used in INSERT, UPDATE, and DELETE statements.
This chapter includes one section on Operators and five sections on functions: Aggregate Functions, Numeric Functions, String Functions, Date Time Functions, and Null Functions.
Table 7-1 lists common operators and Table 7-2 lists common functions.
| Logical Operators | Comparison Operators (Symbols) | Comparison Operators (Keywords) | Math Operators |
|---|---|---|---|
|
|
|
|
| Aggregate Functions | Numeric Functions ... |
|---|
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access