Answer the question
In order to leave comments, you need to log in
How to remove the extra from the request?
SELECT item, SUM(left_items) AS left_items, MAX(price) AS price
FROM dbo.exchange
WHERE time_end>1 AND left_items>0
GROUP BY item, price;
Answer the question
In order to leave comments, you need to log in
Select a.item, a.price,SUM(b.left_items) as left_items from
(Select item, MAX(price) as price from dbo.exchange group by item) a
left join
dbo.exchange b
on a.item=b.item and a.price=b.price
group by a.item, a.price
I think you should use partition by here, like this:
SELECT item,
sum(left_items) over (partition by item order by price) as left_items,
first_value(price) over (partition by item order by price) as price
WHERE time_end>1 AND left_items>0
If I understand correctly, it should be like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question