SELECT csi.incident_number,
address1,
address2,
address3,
address4,
csi.customer_id
FROM hz_parties hr, cs_incidents_all_b csi
WHERE NVL (LTRIM (RTRIM (hr.address1)), 'Y') <>'Y'
AND NVL (LTRIM (RTRIM (hr.address2)), 'Y')<>'Y'
AND NVL (LTRIM (RTRIM (hr.address3)), 'Y')<>'Y'
AND NVL (LTRIM (RTRIM (hr.address4)), 'Y')<>'Y'
/*hr.address1 is not null
and hr.address2 is not null
and hr.address3 is not null
and hr.address4 is not null*/
AND csi.customer_id = hr.party_id
AND ROWNUM <5
address1,
address2,
address3,
address4,
csi.customer_id
FROM hz_parties hr, cs_incidents_all_b csi
WHERE NVL (LTRIM (RTRIM (hr.address1)), 'Y') <>'Y'
AND NVL (LTRIM (RTRIM (hr.address2)), 'Y')<>'Y'
AND NVL (LTRIM (RTRIM (hr.address3)), 'Y')<>'Y'
AND NVL (LTRIM (RTRIM (hr.address4)), 'Y')<>'Y'
/*hr.address1 is not null
and hr.address2 is not null
and hr.address3 is not null
and hr.address4 is not null*/
AND csi.customer_id = hr.party_id
AND ROWNUM <5