In round function we can use (4,512,1) but the same is not true for ceil and floor. I want to ceil and my floor the value 4,512 as 4,5 and 4,6 but the decimal point 1 is not always constant. it may vary. For Floor with decimal points the trunc function can be used. Is there a way to perform ceil with decimal points ?
how to perform oracle ceil with decimal points
208 views Asked by DataGeek At
2
There are 2 answers
1
Littlefoot
On
CEIL and FLOOR return the closest integer and don't accept any arguments (but the number itself).
So, if you want to do that up to the 1st decimal, first multiply the number by 10, CEIL/FLOOR that value, and then divide it by 10.
Something like this:
SQL> with test (col) as (select 4.521 from dual)
2 select col,
3 --
4 ceil(col * 10) / 10 c_ceil,
5 floor(col * 10) / 10 c_floor
6 from test;
COL C_CEIL C_FLOOR
---------- ---------- ----------
4,521 4,6 4,5
SQL>
Related Questions in ORACLE
- sqlplus myusername/mypassword@ORCL not working with Oracle on Docker
- Oracle setting up on k8s cluster using helm charts enterprise edition
- Oracle Managed Data Access Client can't work from IIS but work for local debug environment
- If composite indexing created - indexing is called?
- Oracle Http server ISNT-07551
- why here not creating table?
- Data migration from Oracle Database Clob to GCP Bucket
- SQL Alchemy custom type, forcing blob bind parameter
- How to send message to syslog agent in plsql
- Whatever the data available in previous record it should add to the new record
- I have an Oracle SQL query that is giving me a "ORA-00918: column ambiguously defined" error on a line that is a comment line
- 'ORA-12170: TNS:Connect timeout occurredORA-12170: TNS:Connect timeout occurred' ERROR while working on oracle with laravel
- Is their any way i can open parallel query tabs
- VSCode Libraries not showing for New Java Project
- I can't ssh to my instance, Connection refused
Related Questions in ROUNDING
- In the python fractions module, why is a result of round() sometimes incorrect?
- How to round values in pyplot table
- why does the default round function in python fix double rounding errors?
- SSRS - Do not want to round a percent
- Understanding Python's Decimal.quantize method
- Isometric Tilemap is Not Lining Up Properly
- Algorithm for rounding and clamping a number to specific ends
- Character and Numeric vectors, preserve decimal points in R
- Rounding error for residuals in GARCH mean model
- Why does gcc -O1 affects std::rint()?
- How can I round numbers with three or more digits after the decimal point accurately?
- How do I make the rounding function of athena match redshift?
- Rounding of binary floating point number's mantissa
- Round prices in woocommerce without rounding the total tax at cart and checkout
- Floating point serialization/parsing rounding
Related Questions in TRUNCATE
- Why am I encountering an error with comm.Bcast() function in mpi4py when broadcasting a numpy array?
- avoid sas removing trailing space
- Remove everything before certain point of a string
- Databricks notebook how to stop truncating numbers when export the query result to csv
- Is there a way to truncate the beginning of numpy memmap files?
- SSIS Truncation may occur due to inserting data from data flow column with a length of 250 to database column with a length of 16
- How to truncate a String in the middle with ellipsis POSIX compliant?
- Truncate longer text-chips before shorter will be truncated
- How to truncate string before POST?
- Avoid "String is too long" Warning with LISTAGG in Snowflake
- Laravel 10: Get the full JSON API Response (not truncated)
- Math.Trunc function reducing the value by 0.001
- TTS truncates audio in the middle of the recording - skips few sentences
- How to make text-overflow : ellipsis work on textarea in react.js + tailwind css
- Powerlevel10K prompt shorten strategy
Related Questions in FLOOR
- Flutter floor db cannot define return type
- How to fix the error in the color_post function in this code?
- Ceiling and Floor of a number for array in descending order (Java)
- SQL, random number
- How can I get the floor of a large floating-point number at compile-time?
- Flutter Floor Database. Failed to generate the floor database
- strftime coerces all time values to midnight if one entry doesn't have HH:MM
- How to select from a vector of fractions and respect the number of elements?
- save data aggregationly in floor database flutter
- How to implement a floor function that rounds according to integers in a specified array?
- PowerBI DAX: average per time interval
- Postgre floor changes values postgresql
- Why does math.floor() round up numbers after 15 decimal places in python?
- flutter floor floor_generator error: There are no entities added to the database annotation
- Error when generating results in cents (beecrowd - 1021)
Related Questions in CEIL
- Why the height of segment tree is O(logn)
- ceil(double(int)*double) or ceil(float(int*double))?
- Ceiling and Floor of a number for array in descending order (Java)
- How can I move datetime to the closest five minutes?
- How do I get ceil to work when variable on left of '=' is an int, and variable on right is a double?
- How to select from a vector of fractions and respect the number of elements?
- I am unable to use a variable inside of the ceil function even after including the math header file
- Math.ceil ; Math.random
- Printing answer directly using cout gives wrong answer, whereas storing the answer and then printing using cout get accepted
- How to implement a floor function that rounds according to integers in a specified array?
- the regular math formula for "Calculating the index value of a sequence based on a given sequence value." in PineScript
- CEILING fnc in Excel in Javascript?
- How can I plot a discontinuous ceiling function?
- Customized floor/ceiling for dates in R
- PHP ceil calculation differs in result from manually calculated result
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Adapting how the
roundfunction is defined (for positive numbers):... for a general case of a variable ceiling you might want something like:
So you could define your own functions:
Then with some sample data:
you get:
db<>fiddle
You might need to look at negative values to check they behave as you expect/want, and adjust the functions to mimic
roundif necessary. You also said the decimal might be zero, 1 or more; if that could be negative then it will need more work...