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 best solutions below
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
- Column displays each count
- MAX and GROUP BY - SQL
- Best Practice for adding columns to a Table in Oracle database
- Updating an Oracle row with value from same row
- Retrieving data from Oracle database
- Ibatis execute update sql on oracle, it is not working and no exceptions
- Building an sql execution plan history
- Implementation of Rank and Dense Rank in MySQL
- how to update the date field for this specific condition using oracle query?
- Oracle stored procedure wrapping compile error with inline comments
- Android: How to connect oracle database using Android Java code?
- SQL Conditional Join on Columns
- Multi value wildcard search in ibatis
- Get count of consecutive days meeting a given criteria
- How to update the metadata of a layer in Oracle imported through FME Workbench?
Related Questions in ROUNDING
- How to round smoothly percentage in JS
- How to make all variables in javascript script have two decimal points
- Crystal report to rounding
- How to rounding up in oracle
- PHP Round With Decimal & Comma $1,000
- return decimal with two decimal places C#
- summary() rounding
- What am I missing in understanding round() function?
- Go through Cells and Round to Closest 5 VBA
- Sqlite Rounding
- RoundingMode.HALF_DOWN issue in Java8
- Biggest possible rounding error when computing floating-point numbers
- Why is rounding done like this?
- How to round float in c#
- BigDecimal setScale method returning strange results
Related Questions in TRUNCATE
- Java format integer limiting width by truncating to the right
- Is it possible to truncate date to Month with Java 8?
- Truncating HTML content at the end of text blocks (block elements)
- Create table without drop if its exist
- Truncate selected tables in SQL Server
- String data right truncation DB2 error
- Android Textview Truncate
- Truncating variable MATLAB
- Data Truncation on SBS2008
- db2batch -w switch and import operation
- Postgres Trunc return of ST_Area() postGIS
- How to truncate text in select box using CSS only
- Easiest way to truncate / trim last character in a file
- PHP Function and Variable inside echo Tag
- How to truncate a double to four digits in hive without rounding?
Related Questions in FLOOR
- search the column with decimal value for '.'
- Using Floor and Int in a computation
- Floor vs int cast difference
- Difference in dates between servers
- PHP - round() function with PHP_ROUND_HALF_DOWN mode (unexpected behavoir)
- MySQL FLOOR function unexpected results
- value ($age) returns unexpected result
- using Math.Floor
- Using FLOOR() in WHERE clause in MySQL
- floor value in php function
- Truncate results from SQL to integer value
- Cannot get @Typeconverters to work in floor-flutter
- Why floor and ceil functions giving different values when applied on a log function result in c++
- Difference of @value and FLOOR(@value) is 0 for DECIMAL type
- How does x|0 floor the number in JavaScript?
Related Questions in CEIL
- search the column with decimal value for '.'
- How can I round off value in dynamic col-md-(value) in Angular Js?
- PHP - round() function with PHP_ROUND_HALF_DOWN mode (unexpected behavoir)
- MySQL - Rounding (sort of) - Want to round number only if greater than/less than 10
- math.ceil returns float (1.5)
- How can I make sure a float will always be rounded up with PHP?
- DecimalFormat not ceiling properly
- Why floor and ceil functions giving different values when applied on a log function result in c++
- How to round decimals in PHP to match Google's results
- Floor or ceiling of a pandas series in python?
- How can I move datetime to the closest five minutes?
- With PHP, how to check if decimal number is above or less than 50?
- PHP ceil gives wrong results if input is a float with no decimal
- Can I trust a real-to-int conversion of the result of ceil()?
- how to perform oracle ceil with decimal points
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)
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?
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...