1

I have a table like

Blockquote

and i want to summaries like this

enter image description here

So i want to sum packages for distinct items where my table could have multiple records that i can not just exclude cause are different.

I can not just

select sum(package) from table group by buyer,item;

and i can not also devide it with the count(item).

kyrpav
  • 756
  • 1
  • 13
  • 43
  • See [Why should I provide a Minimal Reproducible Example for a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query) , as a image is not a **easy** reproducible example.. – Raymond Nijland Nov 08 '19 at 15:34

1 Answers1

2

you could use a subquery

select sum(package), buyer
from (
  select distinct buyer, package
  from my_table  ) t
group by buyer
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107