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

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

COLUMNS和COLUMN ALIAS

输入:对某列进行类型转换和格式化时,应确保列名和别名相同

1
2
3
4
5
6
7
SELECT Product_Line_ID, MAX(Standard_Price) 
  FROM ( SELECT A.Product_Description, A.Product_Line_ID
   , A.Standard_Price(DECIMAL(18),FORMAT '9(18)')(CHAR(18))  
        FROM product_t A
      WHERE Product_Line_ID in (1, 2) 
  ) AS tabAls 
 GROUP BY Product_Line_ID;

输出

1
2
3
4
5
6
7
SELECT Product_Line_ID, MAX( Standard_Price )
   FROM  ( SELECT A.Product_Description, A.Product_Line_ID
        , CAST( LPAD( CAST(A.Standard_Price AS DECIMAL( 18 ,0 )), 18, '0' ) AS CHAR( 18 ) ) AS Standard_Price 
                 FROM product_t A
               WHERE Product_Line_ID IN( 1 ,2 )
           ) AS tabAls
  GROUP BY Product_Line_ID;
support.huaweicloud.com/tg-dws/dws_16_0099.html