
Explanation:
Given the table sales_table with columns region, product, and sales, which query will rank products within each region by their sales, displaying the region, product, sales, and rank without any gaps in the ranking?

A
SELECT
region,
product,
RANK() OVER (
ORDER BY sales DESC
) AS rank
FROM sales_table;
SELECT
region,
product,
RANK() OVER (
ORDER BY sales DESC
) AS rank
FROM sales_table;
B
SELECT
region,
product,
RANK() OVER (
PARTITION BY product
ORDER BY sales DESC
) AS rank
FROM sales_table;
SELECT
region,
product,
RANK() OVER (
PARTITION BY product
ORDER BY sales DESC
) AS rank
FROM sales_table;
C
SELECT
region,
product,
RANK() OVER (
PARTITION BY region
) AS rank
FROM sales_table;
SELECT
region,
product,
RANK() OVER (
PARTITION BY region
) AS rank
FROM sales_table;
D
SELECT
region,
product,
RANK() OVER (
PARTITION BY region
ORDER BY sales DESC
) AS rank
FROM sales_table;
SELECT
region,
product,
RANK() OVER (
PARTITION BY region
ORDER BY sales DESC
) AS rank
FROM sales_table;
No comments yet.