In the last quiz, you figured out
which select clauses you'd need to
do some particular queries.
Now let's do one of
those queries in SQL.
It's time to take attendance at the zoo.
We need to know how many of
each species we have, and
it would be a big help if we had
the most popular species listed first.
Because, they'll take the most time for
the zookeepers to count.
We've put a cheat sheet of all
the select clauses we've seen so
far, in the instructor notes below
the editor on the next page.
But, you have to put
them together correctly,
into a query that makes sense.
Feel free to take a few tries,
using the test round button.
You'll see the result table down below.
When you've got it, press Submit,
and your query will be tested
against a larger database.
So here's the problem.
Write a query that returns all the
species in the zoo, and how many animals
of each species there are, sorted with
the most populous species at the top.
And here's an example,
if the zoo had 4 gorillas, 2 alpaca,
1 brown bear and no other animals,
then we'd get a result like this.
اكتشفت في الاختبار الأخير
عبارات select التي ستحتاجها لإنشاء
.بعض الاستعلامات المحددة
والآن دعونا نقوم بإنشاء استعلام
.من تلك الاستعلامات في SQL
.حان وقت تفقد الحضور في حديقة الحيوان
نحتاج إلى معرفة عدد
كل صنف من الحيوانات في الحديقة
وسنقدم مساعدة كبيرة إذا قمنا بوضع
.الأنواع الأكثر شعبية على رأس القائمة
لأن مهمة إحصاء هذا سيستغرق معظم وقت
.حراس حديقة الحيوان
لقد قمنا بوضع إرشادات موجزة لكل
عبارات select التي رأيناها حتى
الآن، في ملاحظات المدرب أسفل المحرر
.في الصفحة التالية
لكن، يجب عليك وضعها
،معًا بشكل صحيح
.في استعلام منطقي
،لا تتردد في إعادة المحاولة عدة مرات
.باستخدام الزر الدائري للاختبار
.سترى جدول النتائج بالأسفل
"عندما تعثر عليه، اضغط "إرسال
وسيتم اختبار الاستعلام
.مقابل قاعدة بيانات أكبر
.حسنًا، إليك المشكلة
اكتب استعلامًا يعرض كل أصناف
الحيوانات في حديقة الحيوان وعدد الحيوانات
من كل صنف مع وضع
.الأصناف الأكثر شعبية على رأس القائمة
،على سبيل المثال
إذا كانت حديقة الحيوان بها أربع غوريلات وحيوانان من حيوانات الألباكا
،ودب بني واحد
.إذن، سنحصل على نتيجة مثل هذه
No último teste, você descobriu
quais são as cláusulas select necessárias para
fazer consultas em particular.
Agora vamos fazer uma
dessas consultas em SQL.
É a hora de ir ao zoológico.
Precisamos saber quantas de
cada espécie nós temos, e
seria de grande ajuda se tivéssemos
as espécies mais populares listadas primeiro.
Porque levará mais tempo para
os administradores do zoológico contá-las.
Colocamos uma folha de cola com todas as
cláusulas select que vimos até
agora, nas notas do instrutor abaixo
do editor na próxima página.
Mas, temos que
reuni-las corretamente
em uma consulta que faça sentido.
Sinta-se livre para fazer algumas tentativas
usando o botão test round.
Você verá a tabela de resultados abaixo.
Quando você conseguir, pressione Submit,
e a sua consulta será testada
em um banco de dados maior.
Aqui está o problema.
Escreva uma consulta que retorna todas as
espécies do zoológico e quantos animais
de cada espécie existem, classificados com
as espécies mais populosas no início.
E aqui está um exemplo,
se o zoológico tiver 4 gorilas, 2 alpacas,
1 urso pardo e nenhum outro animal,
então obtemos um resultado como este.
在上一个小测验中 你弄明白了需要用哪个 select 子句
进行某类具体的查询
现在让我们来做一个SQL 中的查询
是时候到动物园来看看了
我们需要知道每个物种有多少动物
如果我们先把数量最多的物种列出来 这会很有帮助
因为这会耗费动物园管理员最多的时间进行统计
我们提供了一份小抄 上面列出了我们到目前为止见到的
所有 Select 子句 它在下一页编辑器下面的讲师注释里
但是 你必须把它们正确组合在一起
形成一个有意义的查询语句
你们可使用圆形的测试按钮随便做几次尝试
你们会在下面看到结果表格
在得到结果表格后 点击提交
你的查询将针对一个更大的数据库
所以这是个问题
写下一条查询语句 返回动物园中所有的物种 以及每个物种
有多少动物 数量最多的物种排在最上面 以此顺序排序
这里有个例子 如果动物园有四只大猩猩 两只羊驼
一只棕熊 没有其它动物 那么我们会得到这样的结果