Microsoft
70-433 · Question #125
You have a table named Products. The table contains a column named Color. You need to write a Transact-SQL statement that calculates the percentage of products of each product color. Which…
The correct answer is C. SELECT Color, (COUNT(*) * 1.0)/ COUNT(*) OVER() AS PercentColor. See the full explanation below for the reasoning.
Question
You have a table named Products. The table contains a column named Color. You need to write a Transact-SQL statement that calculates the percentage of products of each product color. Which Transact-SQL statement should you use?
Options
- ASELECT Color
- BSELECT Color
- CSELECT Color, (COUNT() * 1.0)/ COUNT() OVER() AS PercentColor
- DSELECT Color, COUNT() * 1.0) / COUNT() OVER(PARTITION BY Color)
How the community answered
(42 responses)- A7% (3)
- B5% (2)
- C74% (31)
- D14% (6)
Community Discussion
No community discussion yet for this question.