12 replaced http://stackoverflow.com/ with https://stackoverflow.com/
source | link
11 replaced http://dba.stackexchange.com/ with https://dba.stackexchange.com/
source | link

It very much depends on circumstances and exact requirements. Consider my comment to the questionmy comment to the question.

It very much depends on circumstances and exact requirements. Consider my comment to the question.

It very much depends on circumstances and exact requirements. Consider my comment to the question.

10 format
source | link

It very much depends on the circumstances and exact requirements. Consider my comment to the question.

SQL Fiddle.SQL Fiddle.

 


SQL Fiddle.SQL Fiddle. 


Recursive CTE / JOIN LATERAL JOIN LATERAL / Correlatedcorrelated subquery

Especially for data distributions with many prices per goodmany prices per good:

It very much depends on the circumstances and exact requirements. Consider my comment to the question.

SQL Fiddle.

SQL Fiddle.

Recursive CTE / JOIN LATERAL / Correlated subquery

Especially for data distributions with many prices per good:

It very much depends on circumstances and exact requirements. Consider my comment to the question.

SQL Fiddle.

 


SQL Fiddle. 


Recursive CTE / JOIN LATERAL / correlated subquery

Especially for data distributions with many prices per good:

9 update link
source | link
8 clarify some more
source | link
7 typo
source | link
6 add collation for index
source | link
5 Faster solutions and link
source | link
4 minor edits
source | link
3 hint for covering indices
source | link
2 added 137 characters in body
source | link
1
source | link