ComeçarComece de graça

Commenting - player BMI

Adding comments is a good way to convey what the query is about or information about certain parts of the query.

The sample code is a query on the Players table that returns player name, country of origin and a calculated Body Mass Index (BMI). The WHERE condition is filtering for only players from North America.

You will add the following comment.

Returns the Body Mass Index (BMI) for all North American players from the 2017-2018 NBA season

Also, you believe that ORDER BY is unnecessary in this query so it will be commented out and a comment added on the same line indicating it is not required.

Este exercício faz parte do curso

Improving Query Performance in SQL Server

Ver curso

Instruções do exercício

  • Create a comment block on lines 1 and 4.
  • Add the above comment to the block.
  • Comment out the ORDER BY statement and add Order by not required comment on the same line.
  • Add ; directly after 'Canada' to indicate the new ending of the query.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.






SELECT PlayerName, Country,
    ROUND(Weight_kg/SQUARE(Height_cm/100),2) BMI 
FROM Players 
WHERE Country = 'USA'
    OR Country = 'Canada'
ORDER BY BMI;
Editar e executar o código