Constraint aggregate functions query packet paging query
Sort query
select * from stu order by age desc;
Aggregate function
Grouping queries
https://www.bilibili.com/video/av55246614/?p=494
select sex 性别,avg(age) 平均年龄,count(id) 人数 from stu group by sex;
Students to identify older than 19 years of age by age Ascending
select * from stu where age >= 19 order by age asc;
having
According to the gender, the number of statistics were older than 19, and then select a number greater than one.
select sex,count(*) as 人数 from stu where age >= 19 group by sex having count(*)>1;
According to the gender, number of people older than 19 are statistics.
select sex,count(*) as 人数 from stu where age >= 19 group by sex;
select name,sex from stu;
select distinct name,sex from stu;
ALL here is a database of the default handling of the same row, it may be omitted.
So SELECT ALL * FROM STUDENT
和 SELECT * FROM STUDENT
It is equivalent to
select sex 性别,avg(age) 平均年龄 from stu group by sex;
And the number of statistics
select sex 性别,avg(age) 平均年龄,count(id) from stu group by sex;
Paging query