Linux 拨号vps windows公众号手机端

python聚合函数有哪些

lewis 6年前 (2019-03-23) 阅读数 8 #程序编程
文章标签 python聚合函数

python中的聚合函数有以下几种

1.count(*)函数

count(*)表示计算总行数,括号中写星与列名,结果是相同的。

count(*)函数使用方法:

#查询学生总数

select count(*) from students;

2.max()函数

max()表示求最大值

max()函数使用方法:

#查询女生的编号最大值

select max(id) from students where gender=2;

3.min()函数

min()函数表示求最小值。

min()函数使用方法:

#查询未删除的学生最小编号

select min(id) from students where is_delete=0;

4.sum()函数

sum()函数表示求和。

sum()函数使用方法:

#查询男生的总年龄

select sum(age) from students where gender=1;

5.avg()函数

avg()函数表示求平均值。

avg()函数使用方法:

#查询未删除女生的编号平均值

select avg(id) from students where is_delete=0 and gender=2;

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门