sql 可以真样写吗? select case b when a='1' then c from table
1个回答
展开全部
select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc
,dwjl, gysbh,gysmc
,sum(fssl) as 销量
,sum(case dwjl when 1 then 1 else 6 end * fssl) as A
from
(
select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxxs_201305 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201306 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201307 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201308 where gysbh = '穗液60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201309 where gysbh = '60203'猜肆物 and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201310 where gysbh = '60203' and yyybh!=''雹巧
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201311 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs where gysbh = '60203' and yyybh!=''
)
,dwjl, gysbh,gysmc
,sum(fssl) as 销量
,sum(case dwjl when 1 then 1 else 6 end * fssl) as A
from
(
select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxxs_201305 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201306 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201307 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201308 where gysbh = '穗液60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201309 where gysbh = '60203'猜肆物 and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201310 where gysbh = '60203' and yyybh!=''雹巧
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs_201311 where gysbh = '60203' and yyybh!=''
union all select mdbh,yyybh,yyymc,spbh,spmc,smbm,fsdwmc,fssl,xsjsl,dwjl, gysbh,gysmc from posmxXs where gysbh = '60203' and yyybh!=''
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询