SQL语句判断这个字段中查出来有为空的,执行另外一个字段填充!急
SELECTsor.orderNoas订单编号,osh.shipmentNoas发货单号,oad.address1as发货地址,oad.firstnameas收件人,oa...
SELECT sor.orderNo as 订单编号, osh.shipmentNo as 发货单号,oad.address1 as 发货地址,oad.firstname as 收件人,
oad.phoneNumber as 联系电话,CONVERT(varchar(10),sor.createTime,23) as 订购日期,
cast(osk.quantity as varchar(50))+'('+cast(osk.measureUnit as varchar(10))+')' as 数量,
cast(osh.shipmentNo as VARCHAR(20))+'('+cast(pro.productcode as varchar(50))+')' as 条形码,
osk.productName as 配件名称,
pro.brandName as 配件类型,-----(这个字段查出来有为空的,就换成pro.accessoryType)
osk.quantity*osk.price as 金额,
osk.buyerCompanyName as 单位
FROM SALES_ORDER as sor,ORDER_SHIPMENT as osh,ORDER_SKU as osk,ORDER_ADDRESS as oad, PRODUCT as pro,
PRODUCT_SKU as psk
WHERE sor.salesOrderId = osh.salesOrderId
and osh.ordershipmentId=osk.ordershipmentId
and osh.shippingAddressId=oad.orderAddressid
and osk.productskuid=psk.productskuid
and pro.productid=psk.productid 展开
oad.phoneNumber as 联系电话,CONVERT(varchar(10),sor.createTime,23) as 订购日期,
cast(osk.quantity as varchar(50))+'('+cast(osk.measureUnit as varchar(10))+')' as 数量,
cast(osh.shipmentNo as VARCHAR(20))+'('+cast(pro.productcode as varchar(50))+')' as 条形码,
osk.productName as 配件名称,
pro.brandName as 配件类型,-----(这个字段查出来有为空的,就换成pro.accessoryType)
osk.quantity*osk.price as 金额,
osk.buyerCompanyName as 单位
FROM SALES_ORDER as sor,ORDER_SHIPMENT as osh,ORDER_SKU as osk,ORDER_ADDRESS as oad, PRODUCT as pro,
PRODUCT_SKU as psk
WHERE sor.salesOrderId = osh.salesOrderId
and osh.ordershipmentId=osk.ordershipmentId
and osh.shippingAddressId=oad.orderAddressid
and osk.productskuid=psk.productskuid
and pro.productid=psk.productid 展开
4个回答
展开全部
1安装oracle client
2 add new service (写客户端tnsname.ora文件)
配置实例名,ip,端口号
3 用sqlplus访问数据库
2 add new service (写客户端tnsname.ora文件)
配置实例名,ip,端口号
3 用sqlplus访问数据库
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
isnull(pro.brandName,pro.accessoryType) as 配件类型
追问
试过了,不行!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
case( when pro.brandName is null then pro.accessoryType end) as 配件类型
追问
语法错误!试过不好使!
case when pro.brandName is null then pro.accessoryType end as 配件类型------这样到是能执行,可是查出来的都是null
追答
pro.accessoryType的值本来就是NULL的话,结果是NULL没错呀,有不是的?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql查询不要用中文,使用英文查出结果字段就可以啦。
追问
这个跟中文英文没有什么关系吧!那个AS出来的列名!你是没看懂题吧!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询