The below link shows the same question that was asked which I want to ask and the code which was provided to answer the query, I used this query (modified it) but please how do I add a join table and a where clause in this query? see below the code I have added to the code in the link below but I am getting error messages. I would like the output to be same as the one provided in the link below
Joining multiple rows into a single row without aggregation [Oracle]
Bare in mind that the desired result provided in the link is my same desired results.
Below is the script which I have modified:
select max(case when seqnum = 1 then p.PERSONID end) as PersonID,
max(case when seqnum = 1 then t.PHONEID end) as PhoneID1,
max(case when seqnum = 1 then t.PHONENUM end) as PhoneNum1,
max(case when seqnum = 1 then t.TYPE end) as Type1,
max(case when seqnum = 1 then t.ISPRIMARY end) as IsPrimary1,
max(case when seqnum = 1 then t.ROWSTAMP1 end) as Rowstamp1,
max(case when seqnum = 2 then t.PHONEID end) as PhoneID2,
max(case when seqnum = 2 then t.PHONENUM end) as PhoneNum2,
max(case when seqnum = 2 then t.TYPE end) as Type2,
max(case when seqnum = 2 then t.ISPRIMARY end) as IsPrimary2,
max(case when seqnum = 2 then t.ROWSTAMP1 end) as Rowstamp2,
max(case when seqnum = 3 then t.PHONEID end) as PhoneID3,
max(case when seqnum = 3 then t.PHONENUM end) as PhoneNum3,
max(case when seqnum = 3 then t.TYPE end) as Type3,
max(case when seqnum = 3 then t.ISPRIMARY end) as IsPrimary3,
max(case when seqnum = 3 then t.ROWSTAMP1 end) as Rowstamp3
from (test1.phone t left join test2.person p
ON t1.PERSONID = t2.PERSONID
where t2.PERSONID = 'MXSDFD'
) t;
rownum as seqnum
from t