Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have one column which is decimal datatype on that column i need
CEILING.PRECISE(Col1,10000)
type working which you find in Excel the output will be as shown in Col3 but i need the value as Col2 for your reference 12758 is less then 15000 thats why Col2 value is 10000 not 20000 as shown in Excel output.

Col1 Col2 Col3
1429 10000 10000
2857 10000 10000
4253 10000 10000
5670 10000 10000
7088 10000 10000
8505 10000 10000
9923 10000 10000
12758 10000 20000
14175 10000 20000
28351 30000 30000
35438 40000 40000

Help me regarding this as currently i am using case statement which is not worth.

Thanks in Advance

What I have tried:

Help me regarding this as currently i am using case statement which is not worth, even thinking of tally table to manage case but not worth at all.
Posted
Updated 24-Feb-16 1:21am

There is no SQL equivelant of the Excell CEILING.PRECISE function - the SQL version only accepts a single parameter and will not "round up" integers to 10000 or any arbitrary value.
However, you can "fake it":
SQL
SELECT CEILING((Col1 + 10000) / 10000)* 10000 FROM MyTable
Should do it.
 
Share this answer
 
Thanks Friend
OriginalGriff
,

I solve the issue the below script is giving me my output

SELECT COALESCE(CASE ROUND(Col1 / 10000,0) WHEN 0 THEN Null ELSE ROUND(Col1 / 10000,0) END * 10000,10000) 


Thanks for your code which give me direction for the output.

Thanks and Regards
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900