0

I have a table like this:

Id Type Price Amount
4284627 sell 307.800000 27.390000
4284640 sell 307.800000 2.670000
4284681 buy 307.600000 0.480000
4284682 buy 307.600000 1.960000

And I am trying to get following result: 2 rows, sum amount of same prices.

Id Type Price Amount
4284627 sell 307.800000 30.06
4284681 buy 307.600000 2.44

Can anyone point me to right direction please?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Orhan Kalayci
  • 73
  • 1
  • 9

1 Answers1

1

You seem to want to group by type as well:

select min(id), type, price, sum(amount)
from t
group by type, price;

But for your question, this works:

select min(id), min(type), price, sum(amount)
from t
group by price;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786