max() 函数
max()函数返回所选列的最大值
select max(column_name) from table_name
min() 函数
min() 函数返回所选列的最小值
select min(column_name) from table_name
count() 函数
count() 函数返回指定条件的行数
select count(column_name) from table_name where condition
count() 与 distinct 结合使用
count(distinct column_name) 函数返回指定列的不同值的树木
select count(distinct column_name) from table_name
avg() 函数
avg() 函数返回数字列的平均值
select avg(column_name) from table_name where condition
sum() 函数
sum() 函数返回数字列的总和
select sum(column_name) from table_name where condition
SQL 日期函数
field() 函数
获取第一条记录
MySQL
select subject_id from qsb_test_list order by subject_id asc limit 1
group by 语句
group by 语句通常与集合函数 (count , max , min , sum , avg)一起使用,以按一个或多个列对结果集进行分组
select column_name from table_name group by column_name
网友评论