LikeLike

]]>LikeLike

]]>I think you have the wrong picture before this text : “Our result set shows no ratios and all 0’s.”

Thank you for all the extremely useful content.

Cheers, Spyros

LikeLike

]]>LikeLike

]]>LikeLike

]]>SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Thanks,

Wayne (USA)

LikeLike

]]>SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Wrong Answer 1 : your are meansed Percentage with decimals, this query division value integer and count result value also integer , so result should be integer

Wrong Answer 3: this query it will provide invalid result set as the numerator and denominator are interchanged.

Sivaguru.u

India

LikeLike

]]>2.SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

because

Option no 1–> displays categories with percentages in integer values.

Option no2 –> displays categories with percentages in decimal values.

Option no 3 –> displays incorrect results.

India

LikeLike

]]>Uday

USA

LikeLike

]]>Clause – Day 11 of 35

A.) Because multiplying an aggregate by 100 (an integer) will result in the nearest integer (1) will not work. Since alculating a category’s percentage of the total products is done by dividing the quantity in the category by the quantity of all the products then multiplying by 100.0 (3) will be incorrect because it is dividing the total (COUNT(*) OVER ( )) by the category (COUNT(*) OVER(PARTITION BY Category)) instead. Because the category’s quantity is being multiplied by 100.0 (a decimal) before being divided by the quantity of all the products it will result in a decimal making (2) the correct answer.

Winner from USA: **Nagaraj Ejanthkar**

Winner from India: **P.Anish Shenoy**

I thank you all for participating here. The permanent record of this update is posted on facebook page.

LikeLike

]]>LikeLike

]]>Will provide with decimals by utilizing the multiplier of 100.0 versus 100

Dan

New Jersey USA

LikeLike

]]>The correct answer is #2.

Love this series.

Eric

USA

LikeLike

]]>I am from India

LikeLike

]]>INDIA

LikeLike

]]>I checked your Facebook link and I didn’t find the winner for this post mentioned explicitly. Its the same page as this one.

Am I missing something ?

Thanks

LikeLike

]]>INDIA

LikeLike

]]>SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Option 1 -> has results in integer without the decimals

Option 3 -> is wrong as it has total product count in the numerator

country : USA

LikeLike

]]>COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

To calculate the percentage (with decimals) of products in each product Category.

LikeLike

]]>2.SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Vinay,

Pune

India

LikeLike

]]>The answer for the above question is Option no 2 is the correct Option as this calculates the percentage (with decimals) of products in each product Category with decimals

2. SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Option 1) This gives us the results products in each product Category but with out decimals

Option 3)This option provide invalid result as the numerator and denominator are reversed and will not fetch the result.

So the option left and which gives us the result is is option no 2.

DILIP KUMAR JENA

Country : INDIA

LikeLike

]]>Sddesh

USA

LikeLike

]]>Shyam

Country: USA

LikeLike

]]>SELECT DISTINCT Category,

COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

because option 1 show result wih no decimals, and option 3 whow wrong information

Leonardo

From: Chile

LikeLike

]]>COUNT(*) OVER (PARTITION BY Category)*100.0/ COUNT(*) OVER() as PctCategory

FROM CurrentProducts

Gordon Kane

Allen TX

USA

LikeLike

]]>