[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

SQL rounding problem

Hello EE,

lets say I have this code:

DEClare @test decimal(10, 4)

set @test = 333.3334


How could I do a select that returns 2 decimals, but   like that:   333.34

because I have a 4 at the end... I would like to show 333.34  
the thing is that I saved inside table as money and it saves 4 decimals. I have a 4 at the fourth decimal.

any ideas.. ?
0
PhilippeRenaud
Asked:
PhilippeRenaud
  • 2
1 Solution
 
Ephraim WangoyaCommented:

select Round(@test, 2)
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that would mean round up?

please check out these expression to choose what you actually need:
DEClare @test decimal(10, 4)
set @test = 333.3334
select @test, round(@test, 2), ceiling(@test), ceiling(@test * 100) / 100, floor( @test) , floor(@test * 100) / 100

Open in new window


0
 
PhilippeRenaudAuthor Commented:
ahhh floor works....!

thanks angel
0
 
PhilippeRenaudAuthor Commented:
sorry I meant Ceiling  *100
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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now