[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

SQL Trunating Decimal

Hopefully this is an easy question but i am new to sql and having problems

What i want to do is calculate a LTV this returns me a percenatage for example

95.25 what i would like to do is truncate any decimal places but do not round up.

so 95.75 would be 95
0
Steege
Asked:
Steege
  • 2
1 Solution
 
rafranciscoCommented:
Try this one:

SELECT ROUND(95.75, 0, 1)
0
 
rafranciscoCommented:
In the ROUND function, the second parameter is the number of decimal places you want in the output while any non-zero numeric value in the third parameter means you want the result truncated.
0
 
BillAn1Commented:
you can actually get away with just casting as an integer, since by defualy, floats are truncated, not rounded,
i.e.
select cast(95.75 as integer)
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