[英]Round in Oracle SQL
I have below SQL that returns the result, but I want the price to rounded to 6 decimal places. 我在下面的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
When I add below it gives me error 当我在下面添加时,它给我错误
ORA-00923: FROM keyword not found where ORA-00923:在哪里找不到FROM关键字
Thanks for your help. 谢谢你的帮助。
The case
needs to go into the round()
. 该
case
需要进入round()
。 You are confusing the function with the alias: 您将函数与别名混淆:
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
end as round(price,6) does'nt work. 结束,因为回合(价格,6)不起作用。 You are aliasing the column as "round(price,6)"
您将列别名为“ round(price,6)”
rather do a 宁愿做一个
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.