- SQL functions
- Avg
Select AVG (col) as Avgvalue from TableName
Select Col2 from tablename where col1> (select AVG (col1) from TableName)
- COUNT return value does not contain a null value
Select COUNT (*) from TableName Returns the number of rows
Select COUNT (DISTINCT col) from TableName returns the unique value of the column
- First returns a value
Select First (col) as colname from TableName
- Last return value
Select Last (col) as colname from TableName
- Max Returns the maximum value
- Min returns the minimum value
- Sum returns the sum
- GROUP by
Select col1, sum (col2) from TableName GROUP by col1
- Having
Select Custom, sum (price) from tablename where custom = ' Tom ' or the custom = ' Jerry ' GROUP by Custom has sum (price) >100 0
- UCASE convert characters to uppercase
Select UCASE (col) from TableName
- LCASE character to lowercase
- MID Extract Characters
Select MID (col, starting number, length) from TableName
- LEN Extract character length
- ROUND rounding a specified number of digits
Select ROUND (col, number of digits) from TableName
- Now returns the current time and date
Select Now () from TableName
- FORMAT
Select FORMAT (now (), ' Yyyy-mm-dd ') from TableName
SQL Learning Note: functions