Member since
09-21-2018
2
Posts
0
Kudos Received
0
Solutions
09-25-2018
09:20 AM
Thank you Tim. Double is not working in my case, currently i am using case statement to get the desired result (i need maximum 2 digits after decimal, so i have only 3 scenarios in case statement). Looking forward to the fix. Thanks, Nitin
... View more
09-21-2018
12:25 PM
Hi Alex, it works using the solution you provided, however if i use variable/column to indicate the number of digits after decimal point then it throws an error, which is : "AnalysisException: round() must be called with a constant second argument." e.g Below query works perfectly fine select round(cast(test1 as decimal(17,15)),2) as test3 from ( select round(269586/334026 * 100,2) as test1, 1 as test2 )A However this query does not work: select round(cast(test1 as decimal(17,15)),test2) as test3 from ( select round(269586/334026 * 100,2) as test1, 1 as test2 )A the problem lies with the decimal typecast, if i remove it then issue will disappaear however the original issue will appear. Please help, i have been struggling for quite some time with this issue. for my requirement i need to use column name to indicate numbers of digits to round, because the same field(column) may have numbers rounded off to various decimal digits. Thanks in advance. Regards Nitin
... View more