-1

I am working a MySQL statement, but when I query the database with the statement it gives me a long return of decimals. How do I only return the decimal placement of 2 spots?

For example, I am getting a return of 8.990999794006347 and I want to get a return placement of just 8.99. Here is my statement to query the database or just that table:

Select movieID, title, year, discountPrice - (.10 * discountPrice) AS 'My Price' From Movie;

I just need the decimal placement to be of 2.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
john doe
  • 1
  • 7
  • 1
    http://dev.mysql.com/doc/refman/5.6/en/numeric-functions.html – CBroe Oct 16 '14 at 17:39
  • Check this post [http://stackoverflow.com/questions/441600/write-a-number-with-two-decimal-places-sql-server][1] [1]: http://stackoverflow.com/questions/441600/write-a-number-with-two-decimal-places-sql-server – Luc Berthiaume Oct 16 '14 at 17:40
  • Use MySQL's [`ROUND()`](http://dev.mysql.com/doc/refman/5.6/en/mathematical-functions.html#function_round) function. – gen_Eric Oct 16 '14 at 17:40
  • @RocketHazmat i seen a couple of example but where would i place the round method? – john doe Oct 16 '14 at 17:48
  • Also how do i apply this to my statement? – john doe Oct 16 '14 at 17:49

1 Answers1

0

You can use the ROUND() method around your "value".

Select movieID, title, year,
    ROUND(discountPrice - (.10 * discountPrice), 2) AS 'My Price'
From Movie;
gen_Eric
  • 223,194
  • 41
  • 299
  • 337