Hi,
Below is the data comming from my source.
OU_ID ADDR ADDR_LINE_2 ADDR_LINE_3 CITY COUNTRY STATE ZIPCODE ADDR_TYPE_CD
1-101UUF Al. Jerozolimskie 195a Warszawa Poland 02-222 D&B
1-101UUF Al. Jerozolimskie 195A Warsaw Poland 02-222
1-10AX-7 8F., No. 560, Sec. 4, Zhongxiao E. Rd. TAIPEI Taiwan OneCode
1-10AX-7 8F, 560, Chung Hsiao E. Rd., Sec. 4, Taipei City Taiwan TAP 11071 D&B
1-10AX-7 8F, No. 560, Sec. 4, Zhongxiao E. Road, Taipei 1071, Taiwan, R.O.C. Taipei Taiwan
1-10AX-7 8F, No.560, Sec.4, Zhongxiao E. Road, 110 ????????????560?8? Taipei 11071 Taiwan
I want output as below order based on ADDR_TYPE_CD
OneCode
"null" value
Local
Other
like
1-10AX-7 8F., No. 560, Sec. 4, Zhongxiao E. Rd. TAIPEI Taiwan OneCode
1-101UUF Al. Jerozolimskie 195A Warsaw Poland 02-222
If none of the above address types exist we should use D&B address for Billing Address (in addition to mapping it to Shipping Address).
Please help me a SQL to resolve.