Functions
Learn SQL functions with practical examples and guided drills on dbSyntax.
Start with FunctionsFunctions
Scalar and aggregate functions for transforming, conditioning, and summarizing values inside a query. This umbrella covers conditional logic...
CASE
Inline conditional expression. Evaluates WHEN branches top-to-bottom and returns the first match; returns ELSE (or NULL if omitted) when not...
ROUND / FLOOR / CEIL
Control numeric precision and bucketing. ROUND(x, n) rounds to n decimal places (negative n rounds to tens/hundreds). FLOOR and CEIL round t...
COUNT / SUM / AVG
Core aggregates. COUNT() counts rows, COUNT(col) counts non-null values, COUNT(DISTINCT col) counts unique non-null values. SUM and AVG igno...
DATE_TRUNC
Round a timestamp down to a coarser granularity (hour, day, week, month, quarter, year). Essential for time-series rollups: group by DATE_TR...
TRIM / LOWER / UPPER
Normalize text for comparison, grouping, or display. TRIM strips leading and trailing whitespace (or a specified character set). LOWER / UPP...