Link to home
Start Free TrialLog in
Avatar of toooki
toooki

asked on

Oralce query question

I have an Oracle 11g table and its contents are like this:
ID   V1   F1   F2    F3
=======================
1    p    12   null  null    
2    q    null 11    null
2    r    null null  17
4    r    null null  23
5    p    8    null  null
4    p    18   null  null
4    q    null 56    null
7    p    17   null  null

How can I write a query that will give following O/P:
ID   F1   F2    F3
=======================
1    12   null  null    
2    null 11    17
4    18   56    23
5    8    null  null
7    17   null  null

The Value of V1 in the first table could only be "p", "q" or "r".
If V1=p then we only need its F1 value.
If V1=q then we only need its F2 value.
If V1=r then we only need its F3 value.
And the O/P needs to have unique ID value.
ASKER CERTIFIED SOLUTION
Avatar of tigin44
tigin44
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of toooki
toooki

ASKER

Yes the solution works perfectly.  But my mistake. I assumed that I could create a view like the below table on which I could use the query that you gave to me.
ID   V1   F1   F2    F3
=================

But I could not create such view. Could you please look at the question that I could correctly put here.
https://www.experts-exchange.com/questions/26833931/Oralce-query-question.html