Price versus the Category Maximum
For products in categories 2 and 3, return category_id, name, price and percent_of_max: the price as a percentage of the highest price in the product's own category, rounded to 1 decimal. Sort by category_id, then by price from high to low, then product_id.
Hint 1
MAX(price) OVER (PARTITION BY category_id) puts the category maximum next to every row.
Reference solution
SELECT category_id,
name,
price,
ROUND(100.0 * price / MAX(price) OVER (PARTITION BY category_id), 1) AS percent_of_max
FROM products
WHERE category_id IN (2, 3)
ORDER BY category_id, price DESC, product_id;
An aggregate with OVER returns the aggregate beside every row instead of collapsing the rows. That makes "row compared with its group" calculations (share of total, difference from average, distance from the best) one-liners. PARTITION BY category_id gives each category its own maximum; with OVER () all the rows of the result form a single window, so every row is compared with the one overall maximum.
Another way. The same result with a correlated subquery. The window version is shorter and reads the table once.
SELECT p.category_id,
p.name,
p.price,
ROUND(100.0 * p.price / (SELECT MAX(price) FROM products WHERE category_id = p.category_id), 1) AS percent_of_max
FROM products AS p
WHERE p.category_id IN (2, 3)
ORDER BY p.category_id, p.price DESC, p.product_id;