Skip to main content
Albero Academy

Built-in Functions

Transform text, numbers and dates in your queries.

Core Queries8 min

SQL has a rich library of built-in scalar functions that transform values row by row — cleaning text, rounding numbers, and extracting date parts, right inside the query.

Common functions

strings, numbers, dates
-- Strings
UPPER(name), LOWER(email), LENGTH(name)
CONCAT(first, ' ', last) -- join strings
SUBSTRING(code, 1, 3), TRIM(name)
-- Numbers
ROUND(package, 1), CEIL(x), FLOOR(x), ABS(x)
-- Dates
NOW(), CURRENT_DATE
EXTRACT(YEAR FROM enrolled) -- or YEAR(enrolled) in MySQL
-- NULL handling
COALESCE(email, 'no email') -- first non-NULL value

Key takeaways

  1. 01Scalar functions transform values row by row inside a query.
  2. 02String (UPPER, CONCAT, TRIM), numeric (ROUND, ABS) and date (EXTRACT, NOW) functions cover most needs.
  3. 03COALESCE returns the first non-NULL value — great for defaults.
  4. 04Exact function names vary by database, but the categories are universal.

Finished this chapter?

Mark it complete to track your progress through SQL.