Q:

How to get the SQL duplicate with different details in single line.?

I want 
1) Gmail type of Email Prefred + OTHER EMAIL Prefered. 
(if there are no other Email type then NULL in EMAIL2, TYPE2, PREFERED_IND2)
2) Gmail type of Email not prefred but OTHER EMAIL is Prefred. 
(if there are no other Email type then NULL in EMAIL2, TYPE2, PREFERED_IND2)
Table: 
ID | NAME | EMAIL           | TYPE    | PREFERED_IND
1  | XYZ  | xyz@gmail.com   | gmail   | Y
1  | XYZ  | xyz@yahoo.com   | yahoo   | Y
2  | ABC  | abc@gmail.com   | gmail   | N
2  | ABC  | abc@hotmail.com | hotmail | Y

Query response 1
ID | NAME | EMAIL         | TYPE  | PREFERED_IND | EMAIL2        | TYPE2 | PREFERED_IND2
1  | XYZ  | xyz@gmail.com | gmail | Y            | xyz@yahoo.com | yahoo | Y

Query response 2
ID | NAME | EMAIL         | TYPE  | PREFERED_IND | EMAIL2          | TYPE2   | PREFERED_IND2
 2 | ABC  | abc@gmail.com | gmail | N            | abc@hotmail.com | hotmail | Y

This is my code:
SELECT ID, Full_Name, TYPE, EMAIL_ADDRESS, PREFERRED_IND 
FROM A 
JOIN A y ON (y.ID = ID) 
WHERE (TYPE != 'GMAIL' AND ( ID IN (SELECT x.ID 
           FROM A x WHERE x.TYPE = 'GMAIL' AND x.PREFERRED_IND = 'Y') ) ) 

A:

SELECT 
    orignal.ID, 
    orignal.Full_Name, 
    orignal.TYPE, 
    orignal.EMAIL_ADDRESS, 
    orignal.PREFERRED_IND,
    joined.TYPE,
    joined.EMAIL_ADDRESS,
    joined.PREFERED_IND
FROM A orignal
    JOIN A joined ON    (
                            joined.ID = orignal.ID
                            AND joined.TYPE = 'GMAIL'
                        ) 
WHERE  orignal.TYPE != 'GMAIL'
AND orignal.PREFERRED_IND = 'Y'
AND orignal.ID IN   (
                        SELECT
                            temp.ID
                        FROM A temp
                        WHERE temp.TYPE = 'GMAIL'
                    );

