I have **3 models** from **3 different tables**: 

```
class Profile(models.Model):
    player_name = models.CharField(max_length=150)
    player_surname=models.CharField(max_length=200)

    class Meta:
        db_table='profiles'

class Results_2019(models.Model):
    player_name = models.CharField(max_length=150) 
    first_score=models.DecimalField(decimal_places=2,max_digits=1000)
    second_score=models.DecimalField(decimal_places=2,max_digits=1000)

    class Meta:
        db_table='results_2019'

class Results_2018(models.Model):
    player_name = models.CharField(max_length=150)         
    first_score=models.DecimalField(decimal_places=2,max_digits=1000)
    second_score=models.DecimalField(decimal_places=2,max_digits=1000)

    class Meta:
        db_table='results_2018'

```

The database is static. Player in all three models have the same names =['Alex','Chandler','Zach'] and they all have data belonging to them for all columns ( `first_score,second_score`)

**Profile database** look like :

```
id player_name    player_surname    

1   Alex           Chapman          
2   Chandler       Wellington           
3   Zach           Berg 

```

**Results\_2019 database** look like :

```
id  profile_id  player_name   first_score   second_score

1      1           Alex         70            68
2      2           Chandler     60            62
3      3           Zach         90            85

```

**Results\_2018 database** look like :

```
id  profile_id  player_name     first_score     second_score

1     1              Alex             78                81
2     2              Chandler         56                66
3     3              Zach             97                95

```

I want to make calculations based on values from Results\_2019 and Results\_2018 to get:

**- players whos growth in first\_score and second\_score in 2019 and in 2018 were more than 20% and then get the name and surnames who met these criteria and print in template.** 

The below formula of criteria though does not work i show as guidance of what i want to achieve. 

```
first_score_growth=((Results_2019.first_score/Results_2018.first_score)*100) 

```

**and** 

```
second_score_growth=((Results_2019.second_score/Results_2018.second_score)*100)

```

What i could do so far :

For this purpose i assigned Foreign key thorugn DB i have seperate column in mysql `prodile_id`. However it does not do even migrations. 

What i could calculate and filter results from **1 DB** table (`Results_2019`):

```
total=Results_2019.objects.annotate(
total_score=(F('first_score') + F('second_score'))/2).filter(total_score__gt=80,)

```

But this calculates total score for year 2019 but not the growth. 

Also when i add foreign key to Results\_2019 it gives me such **OperationalError** (1054, "Unknown column 'Results\_2019.profile\_id' in 'field list'") 

I would appreciate your help to sort this out.