This commit is contained in:
parent
30b336b4cf
commit
fcf74df6a1
1 changed files with 2 additions and 2 deletions
|
|
@ -127,14 +127,14 @@ func (r *repo) getZeroPrices(ctx context.Context, userId int64) ([]ZeroPrice, er
|
|||
q := `
|
||||
WITH price_with_neighbors AS (
|
||||
SELECT
|
||||
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name,
|
||||
p.id, p.created_at, p.merch_id, p.price, p.origin_id, m.name, m.merch_uuid,
|
||||
LAG(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS prev_price,
|
||||
LEAD(price) OVER (PARTITION BY p.merch_id, p.origin_id ORDER BY p.created_at, p.id) AS next_price
|
||||
FROM merch_prices AS p
|
||||
JOIN merch as m ON m.id = p.merch_id
|
||||
WHERE p.deleted_at IS NULL
|
||||
AND m.deleted_at IS NULL
|
||||
AND m.user_id = 3)
|
||||
AND m.user_id = $1)
|
||||
|
||||
SELECT
|
||||
pwn.id, pwn.created_at, pwn.merch_uuid, pwn.name, mo.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue