Click here to Skip to main content
16,004,192 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 29-Mar-13 4:06am
v2
Comments
Richard C Bishop 29-Mar-13 10:14am    
Use this section to add a comment or ask a question or reply to items already posted. You had posted a comment as a solution to your problem. Just a friendly FYI.

Given that you should probably have an ADDR_TYPE_CD table (you do don't you?), you can add a column to order by, bearing in mind that multiple values may share a sort level.
 
Share this answer
 
v2
check this link ...it may be helpfull for u...


http://www.w3schools.com/sql/sql_orderby.asp[^]

or

use this query:

select * from tablename order by ADDR_TYPE_CD;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900