Functions and expressions are used in [[Postgres]] to accomplish various tasks. They can be found in both [[data definition language|DDL]] and [[data manipulation language|DML]] statements, but are most often found in [[SELECT]] statements. ## aggregation Aggregation functions are used in a [[SELECT]] statement that contains a [[GROUP BY]] clause. - `COUNT()` - `SUM()` - `AVG()` - `MIN()` - `MAX()` ## scalar functions Scalar functions can be used on any string values. - `UPPER()` - `LOWER()` - `LENGTH()` - `TRIM()` ## date and time functions See [[working with dates]] for more help on date and time operations. - `NOW()` - `CURRENT_DATE` - [[TO_CHAR]]() - [[EXTRACT]]() - [[CAST]]() - [[DATE_PART]]() ## conversion and casting - [[CAST]]() - :: (PostgreSQL shorthand) ## conditional expressions Conditional expressions can be used for basic logic control flow. - [[CASE]] - `COALESCE()` - `NULLIF()` ## math functions Use math functions with numerical data types. - `ROUND()` - `FLOOR()` - `ABS()` ## string functions Use string functions with strings. - `CONCAT()` - `SUBSTRING()` - `REPLACE()`