ORA-01791: 不是 SELECTed 表达式

[size=xx-small]
select distinct fr.name fname from tms_shipment_carrying_detail t
left join tms_shipment s on s.id=t.shipment_id
left join tms_legs f_leg on f_leg.shipment_id=s.id
left join tms_trans_location tr on tr.id=f_leg.tolocation_id
left join tms_trans_location fr on fr.id=f_leg.fromlocation_id
[color=green]order by[/color] [color=orange]tr.name[/color];
ORA-01791: 不是 SELECTed 表达式!
原因:select distinct 和order by一起使用的时候,order by中必须是常量或者select列表中出现的表达式。(单表时没有这种情况)
改为:
select distinct fr.name fname[color=red],tr.name tname [/color]from tms_shipment_carrying_detail t
left join tms_shipment s on s.id=t.shipment_id
left join tms_legs f_leg on f_leg.shipment_id=s.id
left join tms_trans_location tr on tr.id=f_leg.tolocation_id
left join tms_trans_location fr on fr.id=f_leg.fromlocation_id
[color=indigo]order by[/color] [color=red]tr.name[/color] ; [/size]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值