sql的函数列举
时间:2010-08-19 来源:icybay
分为aggregate函数(针对多值操作)和scalar函数(针对单值操作)。
如果select语句中有select语句嵌套,则必须使用group by
avg():
SELECT AVG(column_name) FROM table_name |
count():
SELECT COUNT(column_name) FROM table_name --or (distinct column_name) |
first() or last():
SELECT FIRST(column_name) FROM table_name |
max() or min() or sum():
SELECT MAX(column_name) FROM table_name |
group by:
SELECT column_name, aggregate_function(column_name) FROM table_name |
having:
SELECT column_name, aggregate_function(column_name) FROM table_name
for example |
ucase() or lcase():
SELECT UCASE(column_name) FROM table_name |
mid() or len():
SELECT MID(column_name,start[,length]) FROM table_name --mid:提取字符 SELECT LEN(column_name) FROM table_name --len:返回文本长度 |
round():
SELECT ROUND(column,decimals) FROM table_name --:decimals:小数位,四舍五入 |
now():
SELECT NOW() FROM table_name --显示当前时间 |
format():
SELECT FORMAT(column_name,format) FROM table_name
SELECT ProductName, UnitPrice, FORMAT(Now(),'YYYY-MM-DD') as PerDate |