QuestionQ35

Executing queries using Databricks SQL and Databricks SQL Warehouses

A data analyst needs to use the sales_table below to obtain each product’s percentage rank within its region, ordered by sales:

Question Image

The query result should appear as follows:

Question Image

Which of the following queries accomplishes this task?

  • A
  • B
  • C
  • D
  • E
Explanation

PERCENT_RANK() calculates a row’s relative rank within a window partition. PARTITION BY region creates separate rankings for EAST and WEST, and ORDER BY sales DESC places the higher-sales product first; with two rows per region, the resulting percentage ranks are 0 and 1. Microsoft Learn: PERCENT_RANK (Transact-SQL)

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!