统计一个班级共有多少学生?
select count(*) from student;
select count(name) from student;
统计数学成绩大于90的学生有多少个?
select count(*) from student where math>90;
统计总分大于250的人数有多少?
select count(*) from student where (math+english+chinese)>250;
统计一个班级数学总成绩?
select sum(math) from student;
统计一个班级语文、英语、数学各科的总成绩
select sum(math),sum(chinese),sum(english) from student;
统计一个班级语文、英语、数学的成绩总和
select sum(chinese+math+english) from student;
统计一个班级语文成绩平均分
select sum(chinese)/count(chinese) from student;
求一个班级数学平均分?
select avg(math) from student;
求一个班级总分平均分
select avg(chinese+english+math) from student;
求班级最高分和最低分
select max(chinese+english+math),min(chinese+english+math) from student;
对订单表中商品归类后,显示每一类商品的总价
select product from orders group by product;
select product,sum(price) from orders group by product;
查询购买了几类商品,并且每类总价大于100的商品
select product from orders group by product having sum(price)>100;
定义带有主键约束的表
create table test1 (
id int primary key,
name varchar(20),