SELECT AVG(column_name) FROM table_n SELECT Customer FROM Orders WHERE OrderPrice>(SELECT AVG(OrderPrice) FROM Orders) #不是where orderprice>AVG(prderprice)!!!!! SELECT COUNT(column_name) FROM table_name #NULL不计入 SELECT COUNT(*) FROM table_name SELECT COUNT(DISTINCT column_name) FROM table_name SELECT FIRST(column_name) FROM table_name SELECT LAST(column_name) FROM table_name SELECT MAX(column_name) FROM table_name SELECT MIN(column_name) FROM table_name SELECT SUM(column_name) FROM table_name SELECT UCASE(column_name) FROM table_name#返回大写 SELECT UPPER(column_name) FROM table_name #返回大写 SELECT LCASE(column_name) FROM table_name #返回小写 SELECT LOWER(column_name) FROM table_name#返回小写
MID() 函数
MID 函数用于从文本字段中提取字符。
SELECT MID(column_name,start[,length]) FROM table_name
LEN() 函数
LEN 函数返回文本字段中值的长度。
SELECT LEN(column_name) FROM table_name
ROUND() 函数
ROUND 函数用于把数值字段舍入为指定的小数位数。
SELECT ROUND(column_name,decimals) FROM table_name
NOW() 函数
NOW 函数返回当前的日期和时间。
FORMAT() 函数
FORMAT 函数用于对字段的显示进行格式化。
SELECT FORMAT(column_name,format) FROM table_name
时间格式转换用DATE_FORMAT()
SELECT SNAME,DATE_FORMAT(SBIRTHDAY,'%d %b %y') AS sdate FROM student
具体日期格式见https://www.w3school.com.cn/sql/func_date_format.asp