将子字符串转换为整数

Convert substring to integer

我编写了一个查询,需要提取 4 位数字字段中的第二个数字。使用子字符串效果很好。但是,我需要新字段是一个整数,而不是一个字符串。我该如何解决这个问题?

CREATE OR REPLACE VIEW vw_uncnload_new  
AS
    SELECT
        icp,
        SUBSTRING(channel, 2, 1) AS channel_no,
        price_category, 
        network_code,
        msn,
        interval_date,
        interval_number,
        compensation_factor,
        read_value
    FROM
        smartco_prod_meterdata.meter_interval

只需使用:

CAST(SUBSTRING(channel, 2, 1) AS int) AS channel_no,