19 lines
621 B
SQL
19 lines
621 B
SQL
WITH
|
|
--targte spreads--
|
|
ts AS (
|
|
SELECT
|
|
t.*
|
|
--, round(target_price/min(target_price) over (partition by mold, chan, season),5) spread
|
|
, target_price/min(target_price) over (partition by mold, chan, season) spread
|
|
FROM
|
|
pricequote.market_setavgprice t
|
|
WHERE
|
|
mold = 'FHR14000'
|
|
and season = 2024
|
|
and chan = 'DIRECT'
|
|
and data_segment like 'v1%'
|
|
ORDER BY
|
|
target_price ASC
|
|
)
|
|
SELECT mold, chan, season, data_segment, spread, max(spread) over (), min(spread) OVER () spread FROM ts WHERE data_segment IN ('v1:B..SLV..','v1:S..SLV..')
|