Sql Query to extract HZ_Geographies data, Query brings Flag set for each Postal Code
Extract HZ_Geographies data, Query brings Flag set for each Postal Code.
SELECT a.geography_id,
a.geography_element2,
a.geography_element3_code,
a.geography_name postal_code,
a.geography_element1_code country,
deli.geography_name delivery_flag,
pri.geography_name priority_flag
FROM apps.hz_geographies a,
(SELECT geography_name,
geography_element4_id,
geography_element3,
geography_element2,
geography_element1
FROM apps.hz_geographies
WHERE 1 = 1 AND geography_type = 'DELIVERY AVAILABLE') deli,
(SELECT geography_name,
geography_element4_id,
geography_element3,
geography_element2,
geography_element1
FROM apps.hz_geographies
WHERE 1 = 1 AND geography_type = 'PRIORITY AVAILABLE') pri
WHERE 1 = 1
AND deli.geography_element3(+) = a.geography_element3
AND deli.geography_element2(+) = a.geography_element2
AND deli.geography_element1(+) = a.geography_element1
AND a.geography_id = deli.geography_element4_id(+)
AND pri.geography_element3(+) = a.geography_element3
AND pri.geography_element2(+) = a.geography_element2
AND pri.geography_element1(+) = a.geography_element1
AND a.geography_id = pri.geography_element4_id(+)
-- AND a.GEOGRAPHY_NAME = '2601'--'5254'
AND a.geography_type = 'POSTAL_CODE'
No comments:
Post a Comment