数据仓库服务 GAUSSDB(DWS)-类型转换和格式化:DECIMAL

时间:2024-12-10 11:29:05

DECIMAL

输入:DECIMAL转换

1
2
3
4
5
6
7
8
9
SELECT
          standard_price (
               DECIMAL( 17 )
               ,FORMAT '9(17)'
          ) (
               CHAR( 17 )
          )
     FROM
          db_pvfc9_std.Product_t;

输出

1
2
3
4
SELECT
          CAST( LPAD( CAST( standard_price AS DECIMAL( 17 ,0 ) ) ,17 ,'0' ) AS CHAR( 17 ) )
     FROM
          db_pvfc9_std.Product_t;

输入:DECIMAL转换

1
2
3
4
5
6
7
8
9
SELECT
          standard_price (
               DECIMAL( 17 ,0 )
               ,FORMAT '9(17)'
          ) (
               VARCHAR( 17 )
          )
     FROM
          db_pvfc9_std.Product_t;

输出

1
2
3
4
SELECT
          CAST( LPAD( CAST( standard_price AS DECIMAL( 17 ,0 ) ) ,17 ,'0' ) AS VARCHAR( 17 ) )
     FROM
          db_pvfc9_std.Product_t;

输入:DECIMAL转换

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SELECT
          customer_id (
               DECIMAL( 17 )
          ) (
               FORMAT '9(17)'
          ) (
               VARCHAR( 17 )
          )
     FROM
          db_pvfc9_std.Customer_t;

输出

1
2
3
4
SELECT
          CAST( LPAD( CAST( customer_id AS DECIMAL( 17 ,0 ) ) ,17 ,'0' ) AS VARCHAR( 17 ) )
     FROM
          db_pvfc9_std.Customer_t;
support.huaweicloud.com/tg-dws/dws_16_0099.html