如下的SQL语句 执行时老报子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的
大家能帮忙看下是什么问题吗
select distinct InnerCode, b.SecuCode as GPDM,b.CompanyCode as vc_ccode, case left( case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0 )+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end ,1) when 'Z' then substring(case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF'else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end,2,len(SecuCode+'SH')) else case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end end as vc_scode, case left(SecuCode,1) when 'Z' then substring(SecuCode,2,len(SecuCode)) else case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0) else SecuCode end end as vc_code , case when exists(select 1 from QT_IndexQuote f where f.InnerCode=b.InnerCode) then 1 else 0 end as isIndex from SecuMain b where b.SecuMarket in (71,73,81,83,89,90,93)
大家能帮忙看下是什么问题吗
select distinct InnerCode, b.SecuCode as GPDM,b.CompanyCode as vc_ccode, case left( case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0 )+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end ,1) when 'Z' then substring(case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF'else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end,2,len(SecuCode+'SH')) else case isnull(SecuMarket,0) when 0 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'OH' end when 83 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SH' end when 90 then case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0)+'OF' else SecuCode+'SZ' end when 73 then SecuCode+'YH' when 74 then SecuCode+'JY' when 72 then SecuCode+'HK' when 71 then SecuCode+'GT' when 89 then SecuCode+'YH' when 81 then SecuCode+'QB' else SecuCode+'OH' end end as vc_scode, case left(SecuCode,1) when 'Z' then substring(SecuCode,2,len(SecuCode)) else case SecuCategory when 8 then ( select c.SecuCode from LC_CodeChange c where c.InnerCode=b.InnerCode and c.CodeDefine=8 and isnull(c.StopDate,0)=0) else SecuCode end end as vc_code , case when exists(select 1 from QT_IndexQuote f where f.InnerCode=b.InnerCode) then 1 else 0 end as isIndex from SecuMain b where b.SecuMarket in (71,73,81,83,89,90,93)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货