--求平均

select  AVG(age) as 年龄 from xuesheng

 

select AVG(chinese) as 语文 from xuesheng where class = 1

 

*只能对数字类型的进行操作

--求个数

select COUNT(*) from xuesheng/*查询表中有多少条数据*/

 

select COUNT(*) from xuesheng where name like '王%'

 

select COUNT(distinct class) from xuesheng

(两个班级)

--求最大值

select MAX(chinese) from xuesheng where class = 1

 

--求最小值

select MIN(chinese) from xuesheng where class = 1

 

--求和

select SUM(chinese) from xuesheng

 

(以上函数括号中都可以加distinct,默认为all)

组合使用

select AVG(age) as 平均年龄,COUNT(*)as 人数 from xuesheng where class = 1

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-12-09
猜你喜欢
  • 2021-09-07
  • 2021-04-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案