172k views
4 votes
Which syntax is valid for creating a computed column in the SELECT clause?

a. Ratio = Height/Weight
b. Ratio as Height/Weight
c. Height/Weight = Ratio
d. Height/Weight as Ratio

User Jthorpe
by
7.9k points

1 Answer

1 vote

Final answer:

The valid syntax for creating a computed column in SQL is 'Height/Weight as Ratio', where 'as' is used to name the computed column created by the division of two other columns.d. Height/Weight as Ratio

Step-by-step explanation:

The correct syntax for creating a computed column in the SELECT clause of an SQL query is 'Height/Weight as Ratio'. This syntax creates a new column in the result set, where the values are the result of the division of the values from the Height column by the values from the Weight column, and the new column is labeled as Ratio.

Options a and c are not valid because the equals sign is not used to alias column names in SQL. Option b uses 'as' but incorrectly places it before the division calculation instead of after it.

Therefore, the valid syntax is option d, which correctly places 'as' after the calculation to give the new computed column a name.

User Marek Rozmus
by
7.6k points