selectsex as `性别`,count(sex) as `人数`
fromtest.titanic
group bysex

round(x,y) 为保留小数位数函数,括号内两个参数,逗号左边的x表示传入的具体数值,逗号右边的y表示要保留小数的位数是几位。小数采用四舍五入。selectsex as `性别`,max(age) as `最高年龄` ,min(age) as `最小年龄`,# 计算均值并保留两位小数round(avg(age),2) as `平均年龄`
fromtest.titanic
group bysex

select
Fare,
count(Fare)
from
test.titanic
group by
Fare
having
count(Fare) > 5

selectFare,count(Fare) as `数量`
fromtest.titanic
group byFare
havingcount(Fare) > 5
order by# 对结果进行倒序排列`数量` desc
as设置的别名。group by语句可以包含任意数目的列。group by 分组时,每个列都必须是有效的列名或是有效的表达式(不能是聚合函数),如果在select中使用表达式,那么在group by中必须指定相同的表达式,不能使用别名。select语句中的每个列都必须在group by语句中给出。null值,则null将作为一个分组返回,如果类中有多行null值,他们将分为一组。group by必须出现在where之后,order by 之前。在使用select查询语句时,系统执行时遵循下面的次序,次序不对系统就会报错无法执行查询。
下一篇:WebADI - 参数的使用