Ordem das Declarações
Para análise estatística, recebemos a tarefa de contar o número de estações em cada linha e organizá-las em ordem crescente do número de estações para cada linha do metrô.
Para fazer isso, precisamos encontrar o número de estações em cada linha do metrô e então classificá-las do menor número de estações para o maior.
Dessa forma, a construtora entenderá quais linhas do metrô eles precisam priorizar para adicionar estações.
É importante para nós entendermos a ordem de escrita das cláusulas, especificamente onde a cláusula GROUP BY deve ser colocada.
Então, a ordem é a seguinte:
- instrução
SELECT; FROM table;- cláusula
WHERE; - cláusula
GROUP BY; - cláusula
ORDER BY; - cláusula
LIMIT.
A partir dessa ordem, é claro que a instrução GROUP BY deve ser escrita APÓS a instrução WHERE (ou após a tabela FROM se não houver filtragem na sua consulta usando SELECT) e também ANTES da instrução ORDER BY.
12345SELECT department, COUNT(employee_id) AS number_of_employees FROM employees WHERE salary > 70000 GROUP BY department ORDER BY number_of_employees
Swipe to start coding
Using the metro_travel_time table, find the number of stations (create a new column, named number_of_stations using station_name and COUNT() function) for each of the lines (line_name). Next, sort the result from smallest to largest.
Note
COUNT(column)is the function that counts the number of rows.
Brief Instructions
- Retrieve
line_nameand the count of rows in thestation_namecolumn. - Add the alias
number_of_stationsto the second column. - Group the data by
line_name. - Sort the result by
number_of_stations.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Incrível!
Completion taxa melhorada para 4
Ordem das Declarações
Deslize para mostrar o menu
Para análise estatística, recebemos a tarefa de contar o número de estações em cada linha e organizá-las em ordem crescente do número de estações para cada linha do metrô.
Para fazer isso, precisamos encontrar o número de estações em cada linha do metrô e então classificá-las do menor número de estações para o maior.
Dessa forma, a construtora entenderá quais linhas do metrô eles precisam priorizar para adicionar estações.
É importante para nós entendermos a ordem de escrita das cláusulas, especificamente onde a cláusula GROUP BY deve ser colocada.
Então, a ordem é a seguinte:
- instrução
SELECT; FROM table;- cláusula
WHERE; - cláusula
GROUP BY; - cláusula
ORDER BY; - cláusula
LIMIT.
A partir dessa ordem, é claro que a instrução GROUP BY deve ser escrita APÓS a instrução WHERE (ou após a tabela FROM se não houver filtragem na sua consulta usando SELECT) e também ANTES da instrução ORDER BY.
12345SELECT department, COUNT(employee_id) AS number_of_employees FROM employees WHERE salary > 70000 GROUP BY department ORDER BY number_of_employees
Swipe to start coding
Using the metro_travel_time table, find the number of stations (create a new column, named number_of_stations using station_name and COUNT() function) for each of the lines (line_name). Next, sort the result from smallest to largest.
Note
COUNT(column)is the function that counts the number of rows.
Brief Instructions
- Retrieve
line_nameand the count of rows in thestation_namecolumn. - Add the alias
number_of_stationsto the second column. - Group the data by
line_name. - Sort the result by
number_of_stations.
Solução
Obrigado pelo seu feedback!
single