SQL provides a wide range of mathematical functions that you can use in your queries. Here are a few examples:
ABS()
- Returns the absolute value of a number.ROUND()
- Rounds a number to a specified number of decimal places.CEIL()
- Returns the smallest integer greater than or equal to a number.FLOOR()
- Returns the largest integer less than or equal to a number.POWER()
- Returns the result of a number raised to a specified power.SQL also provides several functions for working with dates and times. Here are a few examples:
NOW()
- Returns the current date and time.DATE()
- Extracts the date part of a datetime value.TIME()
- Extracts the time part of a datetime value.YEAR()
- Extracts the year from a date value.MONTH()
- Extracts the month from a date value.DAY()
- Extracts the day of the month from a date value.SQL also provides several functions for working with strings. Here are a few examples:
LENGTH()
- Returns the length of a string.SUBSTRING()
- Returns a portion of a string.CONCAT()
- Concatenates two or more strings.UPPER()
- Converts a string to uppercase.LOWER()
- Converts a string to lowercase.Aggregate functions are used to perform calculations on groups of rows. Here are a few examples:
COUNT()
- Counts the number of rows in a group.SUM()
- Calculates the sum of a group of values.AVG()
- Calculates the average of a group of values.MAX()
- Returns the maximum value in a group.MIN()
- Returns the minimum value in a group.