getting the SUM() of claps and at the same time counting bookmarks in one query : I TRIED A LOT OF SOLUTION THAT LOOKS SIMILAR TO MY PROBLEM BUT NO ONE WORKED FOR ME .

i have 5 tables (USERS, POSTS, BOOKMARKS, CLAPS, COMMENTS) 

**USERS** TABLE:
```
+----+-------+----------------+-------------+------------+
| id |  name |     email      |    password |  register  |
+----+-------+----------------+-------------+------------+
|  1 | lofy  | hello@hi.com   |         123 | 2019-05-06 |
|  2 | jake  | jake@joke.com  |         123 | 2019-06-22 |
|  3 | moly  | moly@liky.com  |         123 | 2019-05-15 |
+----+-------+----------------+-------------+------------+
```
**POSTS** TABLE:
```
+----+-------+-------------------+--------------+------------+
| id | title |       body        |    writer_id |    date    |
+----+-------+-------------------+--------------+------------+
|  1 | lofy  | blah blah blah..  |            1 | 2019-05-06 |
|  2 | jake  | blah blah blah..  |            2 | 2019-06-22 |
|  3 | moly  | blah blah blah..  |            2 | 2019-05-15 |
+----+-------+-------------------+--------------+------------+
```
**BOOKMARKED** TABLE:
```
+---------+-----------+
| user_id |   post_id |
+---------+-----------+
|       1 |         1 |
|       2 |         2 |
|       3 |         2 |
+---------+-----------+
```
**CLAPS** TABLE:
```
+---------+-----------+------------+
| user_id |   post_id | claps_times|
+---------+-----------+------------+
|       1 |         1 |          5 |
|       2 |         2 |         13 |
|       3 |         2 |          7 |
+---------+-----------+------------+
```
i used this query to get the posts details + the user name and avatar + how many times this post is bookmarked by the users
```SELECT posts.*, users.name, users.avatar , 
	count(bookmarks.post_id) as bookmarksCount   
	FROM posts 
    LEFT JOIN users ON users.id = posts.owner
	LEFT Join bookmarks ON bookmarks.post_id = posts.id    
    GROUP BY posts.id
    ;
```
EVERY THING IS GOOD TILL NOW .

**THE PROBLEM:** 

i wanted to get the SUM() of the claps for each post so i added 2 more lines to the previous query , this is the query now:

```
SELECT posts.*, users.name, users.avatar , 
	count(bookmarks.post_id) as bookmarksCount ,
    SUM(claps.claps_count) AS totalClaps
	FROM posts 
    LEFT JOIN users ON users.id = posts.owner
	LEFT Join bookmarks ON bookmarks.post_id = posts.id
    LEFT JOIN claps ON claps.post_id = posts.id
    GROUP BY posts.id
    ;
```

THE PROBLEM IS THAT THE RESULT OF THE CLAPS OF THE POST.ID "2" IS DOUBLED IT'S 40 INSTEAD OF 20,
ITS LIKE THE JOIN OF THE COUNT() OF THE BOOKMARKS OF THE POST IS CAUSING THE PROBLEM , IN OTHER WORDS IF THE SUM() OF THE CLAPS ARE 10 AND THE POST IS BOOKMARKED 5 TIMES AFTER COUNT() THAN THE RESULT OF THE CLAPS WILL BE 50 INSTEAD OF 5.

I TRYIED TO SUBQUERY THE SUM() OF THE CLAPS BUT I DIDN'T KNOW HOW TO DO IT .

**CAN YOU PLEASE GIVE ME THE SOLUTION IN SUBQUERY WAY WITH A SOME EXPLANATION CAUSE I WILL ADD THE COUNT() OF THE COMMENTS LATER ON AND MAYBE MORE SUBQUEERIES TOO**

**TY IN ADVANCE**