Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Exam Databricks-Certified-Data-Analyst-Associate Topic 3 Question 24 Discussion

Actual exam question for Databricks's Databricks Certified Data Analyst Associate Exam exam
Question #: 24
Topic #: 3
[All Databricks Certified Data Analyst Associate Exam Questions]

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)

Show Suggested Answer Hide Answer
Suggested Answer: B

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


Contribute your Thoughts:

Brice
14 days ago
I'm going with Option B. It's the most elegant solution and gets the job done without any unnecessary complexity.
upvoted 0 times
Asha
2 days ago
I think Option B is the best choice too. It's straightforward and efficient.
upvoted 0 times
...
...
Kip
19 days ago
Woah, hold up! Using a subquery just to get the percentage rank? That seems a bit overkill, don't you think?
upvoted 0 times
...
Hildegarde
20 days ago
Ah, I see what they're going for with the PERCENT_RANK() function. That should do the trick!
upvoted 0 times
...
Rosamond
21 days ago
You might be right, I overlooked that detail. Option C does seem to be the most appropriate choice for this task.
upvoted 0 times
...
Hana
23 days ago
This query looks straightforward, but I'm not sure if it's using the right window function. Hmm, let me think this through.
upvoted 0 times
Michel
1 days ago
User 3: Maybe option B would be a better choice.
upvoted 0 times
...
Josefa
9 days ago
User 2: I think option A might not be using the correct window function.
upvoted 0 times
...
Noe
13 days ago
User 1: Have you tried using option A?
upvoted 0 times
...
...
Vi
24 days ago
I disagree, I believe Option C is the right query as it uses the PERCENT_RANK() function which is specifically mentioned in the question.
upvoted 0 times
...
Rosamond
28 days ago
I think the correct query is Option A because it includes the RANK() function.
upvoted 0 times
...

Save Cancel