?
Solved

Rounding Question 2

Posted on 2011-04-29
8
Medium Priority
?
386 Views
Last Modified: 2012-05-11
Hello again

DEClare @test decimal(10, 4)
set @test = 333.3334
select ceiling(@test * 100) / 100

indeed result is good with 333.34

but if i put 333.3333    the result is still 333.34    thats not good...

maybe im doing this wrong but i dont understand why it puts a 4 if there is not 4 in 333.3333
0
Comment
Question by:PhilippeRenaud
  • 4
  • 2
  • 2
8 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35492247
because CEILING is rouding up.

possibly you are wording your question incorrectly....
you might not want to do "rounding", actually.

please clarify with a couple of data values => expected result  what you are really trying to achieve?
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35492279
Alright..


if I have 333.3333

in real life we dont have 0.0033 cents" its doest exist

so if in table I have 333.3333   I want to show 333.33  $

if I have 333.3334    I want to show 333.34

if 555.5555       555.55 $

if 888.8889      888.89 $
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 35492319
"if in table I have 333.3333   I want to show 333.33  $
if I have 333.3334    I want to show 333.34"

whats the logic behind this????
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35492394
dont talk about logic just tell me if its possible

the application is too far ahead to modify.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 35492421
your amounts you show are not "real-life", aka not all the amounts possible...

what about 33.3389 ? 33.1234 ? 33.4321  ? 33.9876  etc ...
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35492435
ok let me think.
0
 
LVL 61

Assisted Solution

by:HainKurt
HainKurt earned 1000 total points
ID: 35492642
maybe you need this

ceiling(FLOOR(@test*1000)/10)/100
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35492777
I understansd that the logic is somewhat odd and I need to fix this instead but its not my code.
I will split points with you all but the problem is elsewhere.


thanks,
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question