SQL LEN() – MAX() – MID() – MID() FUNCTIONS
SQL LEN() FUNCTION
SQL LEN() FUNCTION
The LEN() function returns the length of the value in a text field.
SYNTAX
SELECT LEN (column name) FROM table_ name
EXAMPLE
SELECT LEN(Address) as AddressLength FROM Persons
RESULT
AddressLengt
10
8
SQL MAX() FUNCTION
SQL MAX()FUNCTION
The MAX() function returns the largest value of the selected column
SYNTAX
SELECT MAX(Column-name) From table-name.
EXAMPLE
SELECT MAX(OnderPrice) AS LargestOrdePice FROM Orders.
RESULT
Largest Order Price
2500
SQL MID() FUNCTION
SQL MID() FUNCTION
The MID()function is used to extract characters from a text field.
SYNTAX
SELECT MID (column_ name,start(, length)) FROM table_ name
EXAMPLE
SELECT MID( City,1, 4) as SmallCity FROM Persons
RESULT
SmallCity
Sand
Sand
Stav
SQL MN() FUNCTION
SQL MIN() FUNCTION
The MIN() function returns the smallest value of the selected column.
SYNTAX
SELECT MIN (Column_name) FROM table_ name.
EXAMPLE
We have the following “Orders” table:
O-Id OrderDate OrderPrice Customer
1 2011/11/07 1200 Johnson
2 2011/08/15 1500 Brown
3 2011/05/04 600 Johnson
4 2011/05/21 500 Johnson
5 2011/07/30 2500 Taylor
6 2011/10/08 300 Brown
EXAMPLE
SELECT MIN(OrderPrice) AS SmallestOrderPrice FROM Orders