How to convert 1223/100 to 12.23 not 12 in sql server?

  • Thread starter Thread starter TaeHo Yoo
  • Start date Start date
T

TaeHo Yoo

I have a column called "Amount" and this field contains amount as cents.
So when I get the values of it, I do like "select amount / 100 as
amount" which basically ignores cents. Do you know how to get cents?

Thanks a lot
 
TaeHo said:
I have a column called "Amount" and this field contains amount as cents.
So when I get the values of it, I do like "select amount / 100 as
amount" which basically ignores cents. Do you know how to get cents?

Thanks a lot

Hi YaeHo

You can use convert here i think. eg... (in query analyser )

drop table foo
create table foo
(
amount int not null
)
go
insert foo( amount ) values( 94)
go
insert foo( amount ) values (10)
go
select convert( float , amount )/ 10 from foo
 
Back
Top