• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • 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
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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