聚合函数和数学函数

上一篇 / 下一篇  2015-02-04 15:51:06 / 个人分类:数据库

/*数学函数*/
--返回指定数值表达式的绝对值
  
   select abs(-123)
--返回大于或等于指定数值表达式的最小整数
 
 select ceiling(5.33)
 select ceiling(-7.23)
--返回小于或等于指定数值表达式的最大整数
 select floor(5.33)
 select floor(-7.23)
 
--返回数值表达式1的数值表达式2次幂
 select power(3,3)
--返回数值表达式的平方根
 select sqrt(28)
                                            /*聚合函数*/
  
--返回组中各值的平均值,空值将被忽略
  
     select avg(age)as '平均分' from student
  
--返回组的项数。COUNT(*) 返回组中的项数。包括 NULL 值和重复项。如果指定表达式则忽略空值
     select count(*)from student
     select count(age)from student
     select count(distinct age)from student
    
--返回组中值的最小值,空值将被忽略
      select min(age)from student
   
--返回组中值的最大值,空值将被忽略
      select max(age)from student
     
--返回组中值的和,空值将被忽略
      select sum(age) as '总年龄'from student
     

TAG:

 

评分:0

我来说两句

Open Toolbar