I have the following schema:

```
PRODUCT_MASTER_TB

PRODUCT_CODE   CATEGORY   MODEL_GROUP
     A            1            1           
     B            1            1            
     C            1            2
     D            1            2
     E            2            2

SALES_TB

SALES_DATE       PRODUCT_CODE      SOLD_QTY
20150101             A                2
20150101             A                3
20150102             A                4
20150102             B                5
20150103             B                6
20150104             C                7
...

```

What I'd like to select out of these two table is the total amount of sold qty for each product code based on the category and model group the product code is under.

For example:

```
Sales date from 20150101 - 20150104

PRODUCT_CODE   SOLD_QTY_FOR_CATEGORY_MODEL
    A                    20                   
    B                    20
    C                     7
   ...

```

A and B have the same category and model\_group, so if you add their sold qty up, you get 20 each (2 + 3 + 4 + 5 + 6)

I thought about using fetch to solve the above problem, but is there a way of using joins to get the result I want?