行业代码获取最近代码
行业代码数据格式如下
select t.*,length(code1||code2||code3||code4) as templen from industry t
可发现templen跟code关系
templen | value |
1 | code1 |
3 | code2 |
6 | code3 |
10 | code4 |
最终sql
select t.*, case length(code1||code2||code3||code4) when 1 then code1 when 3 then code2 when 6 then code3 else code4 end as industry_code from industry t
查询结果
Become a Linux Programmer