SQL基于订单值 [英] SQL based on order value

查看:72
本文介绍了SQL基于订单值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



以下是来自我的来源的数据。



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			



我想根据ADDR_TYPE_CD输出以下订单



OneCode

null值

本地

其他



喜欢




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	



如果上述地址类型都不存在,我们应该使用D& B地址作为账单地址(除了将其映射到送货地址) 。





请帮我解决一下SQL。


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.

推荐答案

鉴于你应该有一个ADDR_TYPE_CD表(你不是吗?),你可以添加一个列来排序,记住多个值可能共享排序级别。
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.


查看此链接...它可能对您有帮助...





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







使用此查询:



从ADDR_TYPE_CD的tablename命令中选择*;
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;


这篇关于SQL基于订单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆