FLOOR() CEIL() or ROUND()
SELECT ROUND(1+1.6, 0);
= 3
SELECT FLOOR(1+1.6);
= 2
SELECT CEIL(1+1.6);
= 3
Steven Staples
> -Original Message-
> From: Ashley M. Kirchner [mailto:ash...@pcraft.com]
> Sent: July 20, 2010 1:52 PM
> To: mysql@lists.mysql.com
> Subject: Re: [MyS
On 7/20/2010 10:07 AM, Chris W wrote:
I try to avoid asking why but in this case I have to. I can't imagine
wanting to have a list of numbers displayed and not have them all
aligned right with the sane number of digits after the decimal
point. So why would you even want to do this is?
Mark Goodge wrote:
This is the sort of thing that is far better handled in the
application layer, rather than the database layer. PHP, for example,
even has a built-in function which will do this:
setype($value,"float");
I agree about using the application layer, but I like to use type
c
Hi,
Let try '' to treat numeric as character
For example:
select 1+'1.0';
==> 2
select 1+'1.1';
==> 2.1
- Original Message -
From: "Mark Goodge"
To: mysql@lists.mysql.com
Sent: Monday, July 19, 2010 4:31:51 PM
Subject: Re: Decimal p
SELECT IF((col1+col2) = FLOOR(col1+col2),FLOOR(col1+col2), col1+col2)
EXAMPLE>>>
SELECT IF((1+1.1) = FLOOR(1+1.1),FLOOR(1+1.1),1+1.1) Results 2.1
SELECT IF((1+1.0) = FLOOR(1+1.0),FLOOR(1+1.0),1+1.0) Results 2
Regards,
Samrat Kar
-Original Message-
From: Ashley M. Kirchner [mailto:ash.
On 19/07/2010 10:04, Ashley M. Kirchner wrote:
Is there a way to tell MySql to only return '2' in the first select as
opposed to '2.0'? The second select is correct and should remain as such.
Not easily, no.
Basically I have two columns, one with an integer and another with a
de