As I am not good with MySQL query's so I wish someone help me for creating this kind of sql query.

I having two MySQL tables which is describe bellow:

```
Table Name: rating
-------------------
property_id   user_id   area_rate_count   safety_rate_count   friendly_rate_count   walkability_rate_count
4             28        1                 1                   1                     2
5             38        2                 3                   4                     1
5             40        2                 2                   3                     1
6             40        2                 3                   1                     4
10            43        2                 2                   3                     1  

Table Name: listing
-------------------
property_id   title
4             Sample 1
5             Sample 2
6             Sample 3
10            Sample 4
11            Sample 5
12            Sample 6

```

Now first I want to sum each column and divide. (area\_rate\_count, safety\_rate\_count, friendly\_rate\_count, walkability\_rate\_count). For example In `property_id:5` having two times so first calculate column sum and divide by 2.

**After calculation we will get this output:**

```
Table Name: rating (After Calculation)
--------------------------------------
property_id   rate
4             5
5             9 (Divided by 2 because this property_id is two times in table)
6             10
10            8

```

And Finally I want join this result to my `listing` table and result looks something like this:

```
Table Name: listing
-------------------
property_id   title         rate
4             Sample 1      5
5             Sample 2      9 (Divided by 2 becouse property_id is two times in table)
6             Sample 3      10
10            Sample 4      8
11            Sample 5      0
12            Sample 6      0

```

Thanks.