SQL Built-in Functions
1. Aggregate Functions
- AVG(column) – Returns the average value
- COUNT(column) – Returns the number of rows
- SUM(column) – Returns the total sum
- MIN(column) – Returns the smallest value
- MAX(column) – Returns the largest value
2. String Functions
- CONCAT(str1, str2, ...) – Concatenates strings
- LENGTH(str) – Returns the length of a string
- LOWER(str) – Converts string to lowercase
- UPPER(str) – Converts string to uppercase
- SUBSTRING(str, start, length) – Extracts part of a string
- TRIM(str) – Removes spaces from both ends of string
- REPLACE(str, from_str, to_str) – Replaces substring
3. Numeric Functions
- ABS(number) – Absolute value
- CEIL(number) – Rounds up
- FLOOR(number) – Rounds down
- ROUND(number, decimals) – Rounds to decimal places
- MOD(n, m) – Modulus (remainder)
4. Date and Time Functions
- NOW() – Current date and time
- CURDATE() – Current date
- CURTIME() – Current time
- DATEDIFF(date1, date2) – Difference between dates
- DATE_ADD(date, INTERVAL value unit) – Add time to date
- DATE_SUB(date, INTERVAL value unit) – Subtract time from date
- YEAR(date), MONTH(date), DAY(date) – Extract parts of a date
5. Conversion Functions
- CAST(expr AS type) – Converts data type
- CONVERT(expr, type) – Converts data type
6. Conditional Functions
- IF(condition, true_value, false_value) – If-else logic
- IFNULL(expr1, expr2) – Returns expr2 if expr1 is NULL
- NULLIF(expr1, expr2) – Returns NULL if expressions are equal
- CASE WHEN condition THEN result ... ELSE default END – Conditional logic