Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Need to fetch the records based on the attached file.

user8466336Dec 26 2017 — edited Dec 26 2017

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.

Data.jpg

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 |

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 23 2018
Added on Dec 26 2017
1 comment
59 views