I need to fetch new and completed records from a table. Please find the attached image below, in which it shows the data in the table
and also the result I want. I want the total also to be computed.
There are two logics I need : One I need total horizontally by task wise and also vertically by employee wise. The task and Employee are not static. They might be dynamic. For example here I have shown as 3 tasks and 3 users.

TABLE DATA
| TASKNAME | EMP NAME | STATUS | PID |
| Test 1 | JAI | New | 58520 |
| Test 1 | JAI | Completed | 58520 |
| Test 3 | JAI | New | 58520 |
| Test 2 | JAI | New | 58520 |
| Test 1 | JAI | New | 58521 |
| Test 1 | JAI | Completed | 58521 |
| Test 3 | JAI | New | 58521 |
| Test 2 | JAI | New | 58521 |
| Test 1 | JAI | New | 58522 |
| Test 1 | JAI | Completed | 58522 |
| Test 3 | JAI | New | 58522 |
| Test 2 | JAI | New | 58522 |
| Test 1 | RAM | New | 58523 |
| Test 1 | RAM | Completed | 58523 |
| Test 3 | RAM | New | 58523 |
| Test 2 | RAM | New | 58523 |
| Test 1 | RAM | New | 58524 |
| Test 1 | RAM | Completed | 58524 |
| Test 3 | RAM | New | 58524 |
| Test 2 | RAM | New | 58524 |
| Test 1 | GANESH | New | 58525 |
| Test 1 | GANESH | Completed | 58525 |
| Test 2 | GANESH | New | 58525 |
| Test 3 | GANESH | New | 58525 |
| Test 1 | GANESH | New | 58526 |
| Test 1 | GANESH | Completed | 58526 |
| Test 3 | GANESH | New | 58526 |
| Test 2 | GANESH | New | 58526 |
REQUIRED OUTPUT 1
| Completed Status |
| | JAI | RAM | GANESH | Total |
| TEST 1 | 3 | 2 | 2 | 7 |
| TEST 2 | 0 | 0 | 0 | 0 |
| TEST 3 | 0 | 0 | 0 | 0 |
| Total | 3 | 2 | 2 | 7 |
REQUIRED OUTPUT 2
| New Status |
| | JAI | RAM | GANESH | Total |
| TEST 1 | 0 | 0 | 0 | 0 |
| TEST 2 | 3 | 2 | 2 | 7 |
| TEST 3 | 3 | 2 | 2 | 7 |
| Total | 6 | 4 | 4 | 14 |