[英]Round in Oracle SQL
我在下面的SQL中返回结果,但是我希望价格四舍五入到小数点后6位。
select opt.blo,
opt.premiumcurrency,
case
when opt.structurename is not null then opt.basemarketprice /100
when pct = 1 then opt.basemarketprice /100
when pct = 2 then opt.termmarketprice / opt.notional
when opt.notionalcurrency = opt.premiumcurrency then opt.basemarketprice /100
else opt.termmarketpricepercent /100
end as round(price,6)
from interafce opt
当我在下面添加时,它给我错误
ORA-00923:在哪里找不到FROM关键字
谢谢你的帮助。
该case
需要进入round()
。 您将函数与别名混淆:
round(case when opt.structurename is not null then opt.basemarketprice /100
when pct = 1 then opt.basemarketprice /100
when pct = 2 then opt.termmarketprice / opt.notional
when opt.notionalcurrency = opt.premiumcurrency then opt.basemarketprice /100
else opt.termmarketpricepercent /100
end, 6) as roundedPrice
结束,因为回合(价格,6)不起作用。 您将列别名为“ round(price,6)”
宁愿做一个
select .....
....
when opt.structurename is not null then round(opt.basemarketprice /100,6)
when pct = 1 then round(opt.basemarketprice /100,6)
when pct = 2 then round(opt.termmarketprice / opt.notional,6)
when opt.notionalcurrency = opt.premiumcurrency then round(opt.basemarketprice /100,6)
else round(opt.termmarketpricepercent /100,6)
end as rounded_price
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.