數據庫表 students

1、平均值avg
語法:select avg(列名)from 表名
例:select avg(age)as age_avg from students
as的意思是將輸出的列名重定義,以as后面的文字輸出
結果:
2、返回指定條件的行數
返回指定列的值的數量(null不做計算)
如果不加列名,以*代替則返回表中的數量
語法:select count(列名)from 表名
返回指定列剔除重復數據的數量
語法:select count(distinct 列名)from 表名
例:select count(*)as students_number from students
結果:

3、返回第一條、最后一條、最大值、最小值、相加的和所在的數據
第一條:first()
最后一天:last()
最大值:max()
最小值:min()
相加的和:sum()
語法:select first/last/max/min/sum(age)as age_avg from students
執行參照1、2條例子
4、分組
語法:select 列名 from 表名 where 列名=值 group by 列名
where作為判斷語句可有可無
例:select sum(age),address from students group by address
結果:

5、返回文本字段中值的長度
語法:select len(列名)from 表明
6、返回當前的日期和時間
語法:select now() from 表名
7、對函數顯示的字段進行格式化
語法:select format(列名,指定顯示格式)from 表名
8、將函數字段的值轉化為大寫
語法:select ucase(列名)from 表名
9、將函數字段的值轉化為小寫
語法:select lcase(列名)from 表名
非學無以廣才,非志無以成學
——定一個小目標,每天進步一點點