日期:2014-05-18 浏览次数:20734 次
select (case when substring(客户编码,2,1)>'9' then '国外' else '国内' end) as 客户,sum(销售额) from tb group by (case when substring(客户编码,2,1)>'9' then '国外' else '国内' end)
------解决方案--------------------
select (case when substring(客户编码,2,1)>'9' then '国外' else '国内' end) as 客户, sum(销售额) from tb group by (case when substring(客户编码,2,1)>'9' then '国外' else '国内' end)
------解决方案--------------------
select 客户=(case when substring(客户编码,2,1)>'9' then '国外' else '国内' end), sum(销售额) from tb group by (case when substring(客户编码,2,1)>'9' then '国外' else '国内' end)
------解决方案--------------------
select case when substring(客户编码,2,1) between '0' and '9' then '国内' else '国外' end , sum(销售额) 销售额 from 原表 group by case when substring(客户编码,2,1) between '0' and '9' then '国内' else '国外' end