• Status: Solved
• Priority: Medium
• Security: Public
• Views: 388

# Rounding Question 2

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
PhilippeRenaud
• 4
• 2
• 2
2 Solutions

Billing EngineerCommented:
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

Author Commented:
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

Sr. System AnalystCommented:
"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

Author Commented:
dont talk about logic just tell me if its possible

the application is too far ahead to modify.
0

Billing EngineerCommented:
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

Author Commented:
ok let me think.
0

Sr. System AnalystCommented:
maybe you need this

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

Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.