不超过两个参数的情况通用语句:
select * from
(
select left(N1,4) as N from 表1
union
select iif(instr(N1,";")>0,right(left(N1,instr(N1,";")-1),4),iif(instr(N1,",")>0,right(left(N1,instr(N1,",")-1),4),null)) from 表1
union
select iif(instr(N1,";")>0,left(right(N1,len(N1)-instr(N1,";")),4),iif(instr(N1,",")>0,left(right(N1,len(N1)-instr(N1,",")),4),null)) from 表1
union
select right(N1,4) from 表1
union
select left(N2,4) from 表1
union
select iif(instr(N2,";")>0,right(left(N2,instr(N2,";")-1),4),iif(instr(N2,",")>0,right(left(N2,instr(N2,",")-1),4),null)) from 表1
union
select iif(instr(N2,";")>0,left(right(N2,len(N2)-instr(N2,";")),4),iif(instr(N2,",")>0,left(right(N2,len(N2)-instr(N2,",")),4),null)) from 表1
union
select right(N2,4) from 表1
union
select left(N3,4) from 表1
union
select iif(instr(N3,";")>0,right(left(N3,instr(N3,";")-1),4),iif(instr(N3,",")>0,right(left(N3,instr(N3,",")-1),4),null)) from 表1
union
select iif(instr(N3,";")>0,left(right(N3,len(N3)-instr(N3,";")),4),iif(instr(N3,",")>0,left(right(N3,len(N3)-instr(N3,",")),4),null)) from 表1
union
select right(N3,4) from 表1
union
select left(N4,4) from 表1
union
select iif(instr(N4,";")>0,right(left(N4,instr(N4,";")-1),4),iif(instr(N4,",")>0,right(left(N4,instr(N4,",")-1),4),null)) from 表1
union
select iif(instr(N4,";")>0,left(right(N4,len(N4)-instr(N4,";")),4),iif(instr(N4,",")>0,left(right(N4,len(N4)-instr(N4,",")),4),null)) from 表1
union
select right(N4,4) from 表1
union
select left(N5,4) from 表1
union
select iif(instr(N5,";")>0,right(left(N5,instr(N5,";")-1),4),iif(instr(N5,",")>0,right(left(N5,instr(N5,",")-1),4),null)) from 表1
union
select iif(instr(N5,";")>0,left(right(N5,len(N5)-instr(N5,";")),4),iif(instr(N5,",")>0,left(right(N5,len(N5)-instr(N5,",")),4),null)) from 表1
union
select right(N5,4) from 表1
union
select left(N6,4) from 表1
union
select iif(instr(N6,";")>0,right(left(N6,instr(N6,";")-1),4),iif(instr(N6,",")>0,right(left(N6,instr(N6,",")-1),4),null)) from 表1
union
select iif(instr(N6,";")>0,left(right(N6,len(N6)-instr(N6,";")),4),iif(instr(N6,",")>0,left(right(N6,len(N6)-instr(N6,",")),4),null)) from 表1
union
select right(N6,4) from 表1
)
where N<>null and isnumeric(N)
附上最后的结果的附件
[ 本帖最后由 Scarlett_88 于 2009-7-17 13:44 编辑 ] |