強制轉換檢視某個欄位為某個型別的sql

坚持就有光發表於2024-04-10
 select cast(`a`.`status` AS SIGNED INTEGER) AS `status`,`a`.`TAGNAME` AS `TAGNAME` from 
   (select truncate(`v_mes_snapshots`.`numbervalue`,0) AS `status`,
                    `v_mes_snapshots`.`TAGNAME` AS `TAGNAME` from `mysql`.`v_mes_snapshots` where (`v_mes_snapshots`.`TAGNAME` in ('XLTPS_ZYB1_066','XLTPS_ZYB2_070','XLTPS_ZYB3_070','XLTPS_CQB1_066','XLTPS_CQB2_070','XLTPS_CQB3_070','XLTTF_1djyxzs','XLTTF_2djyxzs','XLTTF_3djyxzs','XLTTF_4djyxzs','XLTGD_ZYD1_MN01','XLTGD_ZYD7_MN01'))) `a` union select `b`.`status` AS `status`,`b`.`TAGNAME` AS `TAGNAME` from (select (`b`.`status` or `c`.`status`) AS `status`,'TAGNAME1' AS `TAGNAME` from ((select truncate(`v_mes_snapshots`.`numbervalue`,0) AS `status`,`v_mes_snapshots`.`TAGNAME` AS `TAGNAME` from `mysql`.`v_mes_snapshots` where (`v_mes_snapshots`.`TAGNAME` = 'XLTTF_1djyxzs')) `b` join (select truncate(`v_mes_snapshots`.`numbervalue`,0) AS `status`,`v_mes_snapshots`.`TAGNAME` AS `TAGNAME` from `mysql`.`v_mes_snapshots` where (`v_mes_snapshots`.`TAGNAME` = 'XLTTF_2djyxzs')) `c`)) `b` union select `c`.`status` AS `status`,`c`.`TAGNAME` AS `TAGNAME` from (select (`b`.`status` or `c`.`status`) AS `status`,'TAGNAME2' AS `TAGNAME` from ((select truncate(`v_mes_snapshots`.`numbervalue`,0) AS `status`,`v_mes_snapshots`.`TAGNAME` AS `TAGNAME` from `mysql`.`v_mes_snapshots` where (`v_mes_snapshots`.`TAGNAME` = 'XLTTF_3djyxzs')) `b` join (select truncate(`v_mes_snapshots`.`numbervalue`,0) AS `status`,`v_mes_snapshots`.`TAGNAME` AS `TAGNAME` from `mysql`.`v_mes_snapshots` where (`v_mes_snapshots`.`TAGNAME` = 'XLTTF_4djyxzs')) `c`)) `c`
   

cast(`a`.`status` AS SIGNED INTEGER) AS `status`

相關文章