1

这是我的查询。我得到的结果是19

SQL> SELECT TRUNC(19.00,1) FROM DUAL;

TRUNC(19.00,1)

        19

相反,我需要结果19.0,我将如何做到这一点?

4

3 回答 3

1

As you appear to be using SQL*Plus you can format the column output directly:

SQL> COLUMN target FORMAT 09.9
SQL> SELECT TRUNC(19.00, 1) AS target FROM dual;

TARGET
------
  19.0

Voila...

Otherwise you would need to either set your IDE to dispaly numerics with a trailing decimal place or display it as a VARCHAR2:

SELECT TO_CHAR(TRUNC(19.00, 1), '09.9')
  FROM dual;

Hope it helps...

于 2012-08-09T14:48:37.947 回答
1
select to_char(19, '09.9') from dual;

请参阅数字格式模型

于 2012-08-09T12:06:25.677 回答
0

我想这也应该工作

SELECT TO_CHAR(TRUNC(19.00, 1),'00.9')   FROM dual; 
于 2012-08-09T16:30:00.713 回答