开发者

How to give select digit after decimal point?

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.

I want to modify this query so that it selects two digits after decimal point.


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜