PrepAway - Latest Free Exam Questions & Answers

Which TransactSQL statement should you use?

You have a table named Products. The table contains a column named Color.
You need to write a TransactSQL
statement that calculates the percentage of products of each product
color.
Which TransactSQL
statement should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
SELECT Color
COUNT(*) OVER(PARTITION BY Color)
/ (COUNT(*) * 1.0) AS PercentColor
FROM Products
GROUP BY Color;

B.
SELECT Color
COUNT(*) OVER() / (COUNT(*) * 1.0) AS PercentColor
/ (COUNT(*) * 1.0) AS PercentColor
FROM Products
GROUP BY Color;

C.
SELECT Color, (COUNT(*) * 1.0)/ COUNT(*) OVER() AS PercentColor
FROM Products
GROUP BY Color;

D.
SELECT Color
COUNT(*) * 1.0) / COUNT(*) OVER(PARTITION BY Color) AS PercentColor
FROM Products
GROUP BY Color;


Leave a Reply