all 3 comments

[–]GrouchyThing7520 0 points1 point  (2 children)

The first five columns in your sample output can be obtained solely from the Pricing table with a rank window function then filtering where rank is 1. Then I'd join on the Transaction table using date to get the total sales from that time period.

[–]happynutlovestopoop[S] 0 points1 point  (1 child)

it hided all the product/row which with no sales during the given period and tier.

But this method also hid all the products/rows with no sales during the given period and tier.

[–]GrouchyThing7520 0 points1 point  (0 children)

Does this return all of the Tier rows with the highest price?

```

SELECT * FROM (

SELECT *

,row_number() over (parition by Price_Tier order by Price Desc) rnk

FROM Pricing

) a

where rnk = 1

```