SELECT
CASE
WHEN SUBSTR(code, -2) = '00' THEN
SUBSTR(code, 1, LENGTH(code) - 2)
ELSE
code
END AS code
FROM test_table;
说明:
如果code最后两位是00的话,就截取掉,如果不是的话,就直接取code。
标签:CASE,00,code,END,截取,查询,SUBSTR,sql From: https://blog.51cto.com/u_15406246/11972315