溫馨提示×

python聚合函數有哪些

九三
1515
2021-02-18 11:47:36
欄目: 編程語言

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;

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女