I have two tables

**tbl\_activities**

```
 id | activity 
 1  | activity1
 2  | activity2

```

**tbl\_sub\_activities** 

```
id |activityId   | subActivity   | status 
 1 |  1          | subActivity1  | done
 2 |  1          | subActivity2  | done
 3 |  1          | subActivity3  | ongoing
 4 |  2          | subActivity4  | done
 5 |  2          | subActivity5  | done

```

Scenario:  

An activity can have many subactivities.

if status of subactivity are all done, then activity is done,  

if status of subactivity still has an ongoing, the activity is ongoing.

Question:  

How can I query tbl\_activities to have an output like this.

```
 id | activity  | status
 1  | activity1 | ongoing
 2  | activity2 | done

```

I've done this using PHP but I want to know how to do this using SQL query.