New Year Sale ! 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
Question #: 24
Topic #: 3
[All Databricks-Certified-Data-Analyst-Associate 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:

Nana
2 months ago
Wait, where's the 'D) None of the above' option? You know, for those of us who just want to walk away from this whole thing.
upvoted 0 times
...
Dierdre
2 months ago
Option C? Really? That query looks like a hot mess. I'd rather not get my hands dirty with that one.
upvoted 0 times
Justine
1 months ago
I'm with you on that. Let's steer clear of Option C and find a better way to get the job done.
upvoted 0 times
...
Viki
1 months ago
Yeah, Option C looks like it would take forever to debug. I'd rather go with something more straightforward.
upvoted 0 times
...
Glen
1 months ago
I agree, Option C does seem overly complicated. I would prefer a simpler solution.
upvoted 0 times
...
...
Brice
3 months 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
Thaddeus
2 months ago
Option B does look like the cleanest solution for this task. It's a good choice.
upvoted 0 times
...
Leanora
2 months ago
I agree, Option B seems like the most logical and efficient way to achieve the desired result.
upvoted 0 times
...
Asha
2 months ago
I think Option B is the best choice too. It's straightforward and efficient.
upvoted 0 times
...
...
Kip
3 months 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
3 months ago
Ah, I see what they're going for with the PERCENT_RANK() function. That should do the trick!
upvoted 0 times
...
Rosamond
3 months 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
3 months 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
Matthew
2 months ago
Option B looks like it could be the right one based on the window function used.
upvoted 0 times
...
Michel
2 months ago
Maybe option B would be a better choice.
upvoted 0 times
...
Josefa
3 months ago
I think option A might not be using the correct window function.
upvoted 0 times
...
Noe
3 months ago
Have you tried using option A?
upvoted 0 times
...
...
Vi
3 months 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
3 months ago
I think the correct query is Option A because it includes the RANK() function.
upvoted 0 times
...

Save Cancel