rascal
asked on
SQL: How to query money field for only values with non-zero in the 'cents' portion?
My donation table looks like this:
id int
donation smallmoney
... other fields ...
I wish to run a report selecting ONLY rows where the donation amount has a non-zero in the 'cents' portion of the field. For example, if a row had a donation of 12.66, then I would want to select that row. But if the row had a donation of 12.60, then I would skip that row.
Is such a query even possible? I've been googling with no luck.
Thanks experts!
id int
donation smallmoney
... other fields ...
I wish to run a report selecting ONLY rows where the donation amount has a non-zero in the 'cents' portion of the field. For example, if a row had a donation of 12.66, then I would want to select that row. But if the row had a donation of 12.60, then I would skip that row.
Is such a query even possible? I've been googling with no luck.
Thanks experts!
where cast(monyfield as integer) = monyfield
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
Try this:
HTH
David
PS Scott: why not round to 0 dp?
Try this:
use ExpertsExchange
go
select *
from dbo.SomeTable st
where
floor( st.SomeColumn ) != ceiling( st.SomeColumn )
;
HTH
David
PS Scott: why not round to 0 dp?
David,
Because the OP indicated:
"if a row had a donation of 12.66, then I would want to select that row. But if the row had a donation of 12.60, , then I would skip that row."
Because the OP indicated:
"if a row had a donation of 12.66, then I would want to select that row. But if the row had a donation of 12.60, , then I would skip that row."
Dale,
I guess that I saw cents and missed the explanation of the tens of cents ...
I guess that I saw cents and missed the explanation of the tens of cents ...
ASKER
Thanks Scott - yours was the working solution.