count()用來統計記錄的條數
復制代碼 代碼如下:
mysql> select count(*) from score;
mysql> select count(*) from score where stu_id=901;
sum()求和函數
復制代碼 代碼如下:
mysql> select sum(grade) from score;
mysql> select id,sum(grade) from score where stu_id=901;
avg()求平均值函數
復制代碼 代碼如下:
mysql> select avg(grade) from score where c_name='計算機';
mysql> select c_name,avg(grade) from score group by c_name;
max()求最大值函數
復制代碼 代碼如下:
mysql> select c_name,max(grade) from score where c_name='英語';
mysql> select c_name,max(grade) from score group by c_name;
min()求最小值函數
復制代碼 代碼如下:
mysql> select c_name,min(grade) from score where c_name='中文';
mysql> select c_name,min(grade) from score group by c_name;
Concat拼接函數
復制代碼 代碼如下:
mysql> select Concat(c_name, '(', stu_id, ')')
-> from score order by stu_id;