查询tb表所有数据,结果按age升序排
select * from tb order by age asc

查询tb表所有数据,结果按score降序排序
select * from tb order by score desc

查询tb表所有数据,结果按age升序排,如果age相同的数据,按score降序排
select * from tb order by age asc, score desc

查询sanguo表,对国家列country进行分组
select country from sanguo group by country

查询sanguo表,对国家列country进行分组,并显示每一组的数量
select country,count(*) from sanguo group by country

查询sanguo表,对国家列country进行分组,显示每组的最大战斗力的值attack
select country,max(attack) from sanguo group by country

查询sanguo表,对国家列country进行分组,显示每组的最小战斗力的值attack
select country,min(attack) from sanguo group by country

查询sanguo表,对国家列country进行分组,显示每组的平均战斗力的值attack
select country,avg(attack) from sanguo group by country

查询sanguo表,对国家列country进行分组,显示每组的总战斗力的值attack
select country,sum(attack) from sanguo group by country

查询sanguo表,对国家列country与性别列gender进行联合分组,显示每一组的成员数量
select country, gender, count(*) from sanguo group by country, gender

查询sanguo表,对国家列country列进行分组,筛出战斗力平均值大于80的小组显示
select country from sanguo group by country having avg(country) > 80