A data analyst has been asked to use the below table sales_table to get the percentage rank of products within region by the sales:

The result of the query should look like this:

Which of the following queries will accomplish this task?
A)

B)

C)


The correct query to get the percentage rank of products within region by the sales is option B. This query uses the PERCENT_RANK() window function to calculate the relative rank of each product within each region based on the sales amount. The window function is partitioned by region and ordered by sales in descending order. The result is aliased as rank and displayed along with the region and product columns. The other options are incorrect because:
A) Option A uses the RANK() window function instead of the PERCENT_RANK() function. The RANK() function returns the rank of each row within the partition, but not the percentage rank. Also, the query does not have a GROUP BY clause, which is required for aggregate functions like SUM().
C) Option C uses the DENSE_RANK() window function instead of the PERCENT_RANK() function. The DENSE_RANK() function returns the rank of each row within the partition, but not the percentage rank. Also, the query does not have a GROUP BY clause, which is required for aggregate functions like SUM().
D) Option D uses the ROW_NUMBER() window function instead of the PERCENT_RANK() function. The ROW_NUMBER() function returns the sequential number of each row within the partition, but not the percentage rank. Also, the query does not have a GROUP BY clause, which is required for aggregate functions like SUM().Reference:
1: PERCENT_RANK (Transact-SQL)
2: Window functions in Databricks SQL
3: Databricks Certified Data Analyst Associate Exam Guide
Kathryn
3 months agoBelen
3 months agoLai
3 months agoAleisha
4 months agoVal
4 months agoGaynell
4 months agoKeneth
4 months agoChaya
4 months agoJanella
5 months agoHeike
5 months agoTimmy
5 months agoEladia
5 months agoJolanda
5 months agoDante
5 months agoShoshana
5 months agoNana
1 year agoDierdre
1 year agoJustine
1 year agoViki
1 year agoGlen
1 year agoBrice
1 year agoThaddeus
1 year agoLeanora
1 year agoAsha
1 year agoKip
1 year agoHildegarde
1 year agoRosamond
1 year agoHana
1 year agoMatthew
1 year agoMichel
1 year agoJosefa
1 year agoNoe
1 year agoVi
1 year agoRosamond
1 year ago