How to count different values of records in same column for single id in MYSQL
<p>I have a mysql table like </p>

<p>student table</p>

<pre><code>id|classid|name     |sectionid
--|-------|---------|-------
1 |1      |ashok    |1
2 |1      |viji     |2
3 |2      |sreekesh |1
</code></pre>

<p>class table</p>

<pre><code>id|name
--|----
1 |class1     
2 |class2
</code></pre>

<p>section table</p>

<pre><code>id|name
--|----
1 |A     
2 |B
</code></pre>

<p>homework table</p>

<pre><code>id|classid|activity   |sectionid
--|-------|-----------|---------
1 |1      |test       |1
2 |1      |assignment |2
3 |1      |test       |2
4 |1      |test       |2
5 |1      |assignment |2
6 |2      |assignment |1
</code></pre>

<p>I want to count class1 student's test activity as total test and assignment activity as total homework. 
my expected result is like:</p>

<pre><code>student_name|class_name|total_test|total_assignment|section
------------|----------|----------|----------------|--------
ashok       |class1    |3         |2               |A
viji        |class1    |3         |2               |B
</code></pre>