各位商手请教下,,在一表有一个字段,,,该字段有会员和湖南移动客户两种值,,,怎么写sql统计它的值,,并显示为会员量多少,移动客户是多少,,,,
我写了条sql
select count(*) as 新增会员数量 from td_shop_shopper_info where shopper_type='会员' or shopper_type='湖南移动客户' group by shopper_type
查询出来是这样的:新增会员量
31
34
我写了条sql
select count(*) as 新增会员数量 from td_shop_shopper_info where shopper_type='会员' or shopper_type='湖南移动客户' group by shopper_type
查询出来是这样的:新增会员量
31
34
select shopper_type,count(*) as 新增会员数量 from td_shop_shopper_info group by shopper_type
shopper_type
会员
移动客户
会员
移动客户我是想分别统计它数量
并按行显示出来
会员:31
移动客户:34
select '会员' shopper_type from dual
union all
select '会员' from dual
union all
select '移动客户' from dual
union all
select '移动客户' from dual
union all
select '移动客户' from dual
)
select shopper_type 会员类型,count(*) 新增会员数量 from td_shop_shopper_info group by shopper_type;
========结果=============会员类型 新增会员数量
----------------------
会员 2
移动客户 3