So here is the question again.
We're trying to write a query that returns all the species in the zoo,
along with their populations.
And here is one possible answer.
Select count of star as num, species from animals.
Group by species.
Order by num descending, or desc for short.
And here's what's going on in that query.
Count star as num, and species are the columns that we want to return.
Animals is the table that we're going to select from.
We're aggregating by species and aggregation is the count.
And then we're ordering, by that count column num descending.
By answering this quiz,
we've put together the count aggregation, grouping and ordering.
The query for this exercise did not require the where clause at all,
because we didn't want to exclude any rows from the census.
.حسنًا، إليك السؤال مجددًا
نحاول كتابة استعلام ،يعرض كل الأنواع الموجودة في حديقة الحيوان
.بالإضافة إلى مجموعاتها
.وإليك إحدى الإجابات المحتملة
،تحديد count (*) as num .وspecies من animals
.تجميع حسب الأصناف
،ترتيب حسب العدد تنازليًا .أو desc اختصارًا
وإليك ما يحدث .في ذلك الاستعلام
count (*) as num وspecies .هما العمودان اللذان نريد عرضهما
Animals هو الجدول .الذي سنقوم بالتحديد منه
نقوم بالتجميع حسب الأصناف .ويمثل aggregation العدد
ثم نقوم بالترتيب .حسب عمود العدد "num" تنازليًا
،بالإجابة على هذا الاختبار
قمنا بوضع aggregation للأعداد .وتجميعها وترتيبها معًا
لم يتطلب استعلام هذا التمرين ،عبارة where على الإطلاق
لأننا لم نكن نريد استبعاد .أي صفوف من التعداد
Aqui vai a pergunta de novo.
Estamos tentando escrever uma consulta que retorne todas as espécies do zoológico,
junto com suas populações.
E aqui está uma resposta possível.
Selecione a contagem de estrelas como número, espécie de animais.
Agrupe por espécies.
Ordene por número decrescente, ou desc para resumir.
E isso é o que está acontecendo nessa consulta.
Conte as estrelas como números, e as espécies são as colunas que queremos retornar.
Animais é a tabela na qual vamos selecionar.
Estamos agregando por espécies e a agregação é a contagem.
E estamos ordenando por essa coluna de contagem de número descendente.
Respondendo a este teste,
reunimos a agregação de contagem, agrupando e ordenando.
A consulta deste exercício não exigia a cláusula where,
pois não queríamos excluir nenhuma linha do censo.
又有一个问题
我们正在编写一条查询语句 返回动物园中所有物种
以及每个物种的动物数量
这里是一个可能的答案
Select count (*) as num, 物种 from 动物
Group by 物种
Order by num desc;
这是查询语句的编写方式
Select count (*) as num, 物种这是我们想返回的列
动物就是我们要选择的表格
我们对物种进行聚合操作用的聚合函数是 count
然后我们进行排序 Order by num desc
通过解答这个小测试
我们结合了 count aggregate group by 和 order by
这个查询练习根本不需要用到 where 子句
因为我们不想在统计结果中排除任何一行