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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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