Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Good day,
need some help with aggregations:
I want to show a list of clients and to see how many invoices(just count) contained only one item, 2 items, 3 items and 4 according to quantity field.
this is my data:
CustomerId | InvoiceId | InvoiceLine | ItemId | Quantity |
100237 | 01390082_INV | 1 | 10692016 | 2 |
100237 | 01390082_INV | 2 | 10692016 | 1 |
100237 | 01390083_INV | 3 | 10692016 | 2 |
100237 | 01390083_INV | 6 | 10692016 | 2 |
100237 | 01390084_INV | 7 | 10692016 | 2 |
100237 | 01390084_INV | 8 | 10692016 | 2 |
100083 | 01390090_INV | 1 | 10281004 | 4 |
100083 | 01390090_INV | 2 | 10692016 | 1 |
100083 | 01390091_INV | 3 | 10281004 | 2 |
100083 | 01390091_INV | 4 | 10281004 | 2 |
100083 | 01390092_INV | 5 | 10281004 | 1 |
100083 | 01390092_INV | 6 | 10281004 | 4 |
100083 | 01390093_INV | 7 | 10281004 | 4 |
100237 | 01390089_INV | 1 | 10692016 | 1 |
this what i am trying to get:
CustomerId | 1 item for Invoice | 2 items for Invoice | 3 items for Invoice | 4 items for Invoice | 5 and more |
100237 | 1 | 1 | 2 | ||
100083 | 2 | 2 |
thanks a head
You need to aggregate per invoice, so 01390082_INV has two lines, sum of quantity is (2+1)=3.
Customer 100237 had 4 invoices (sum the lines by invoice):