tags:

views:

40

answers:

2

In database there is column amount which datatype is money. I want to select that row only with two digit after decimal. for this how to write the query?

My query is like this:

SELECT AMOUNT FROM DETAIL_PAGE.

Please modify this query so that it select two digit after decimal point.

+2  A: 

Not sure if this is SQL standard and works elsewhere, but in Oracle you can say

select round(amount,2) from detail_page

-- round(12.345, 2) would return 12.35

or

select trunc(amount,2) from detail_page

-- trunc(12.345, 2) would return 12.34
Thilo
+1  A: 
SELECT AMOUNT - FLOOR(AMOUNT) FROM DETAIL_PAGE

That will get you just the decimal though. I think you want

SELECT FORMAT(AMOUNT, 2) FROM DETAIL_PAGE

Or without commas:

SELECT REPLACE(FORMAT(AMOUNT, 2), ',', '') FROM DETAIL_PAGE
tandu