How to sum with dynamic filter

Hello!

I've the following structure:

Tables:

  1. People
  2. Products
  3. Orders
  4. Orders-Itens
  5. Available Credit
     

The "available credit" table has the limit that each person can order from each item.

I want to make a view that shows how much each person has consumed and how much credit is available for each item.

But I was only able to show the total orders and credit without separating by product.

1 2 96
2 REPLIES 2

How is your available_credit table structured? I'd imagine a ref column to People, a ref column to Products, and a Number or Decimal column indicating their limit, with a record for every possible person-product combination? If so, you can add in virtual columns to this table to sum up the number of products ordered per person, then create a view on this table, grouped by product.

You might find something helpful from this part from a series of videos covering how to make and evolve  a shopping cart app.

  • While not directly related to your specific request (Available Credit), this might point out something that could be helpful.
  • This one deals with including discounts and updating totals.

Kinda sounds like I need to pick this series back up again and include a credit aspect. (^_^)

Top Labels in this Space