日期:2014-05-16 浏览次数:20806 次
// ============1===========移动 select count(*) from (select substr(user.phone, 1, 3) as flag from user)t where flag in ('134', '135', '136', '137', '138', '139', '150', '151', '152', '157', '158', '159', '187', '188')
// ============2===========联通 select count(*) from (select substr(user.phone, 1, 3) as flag from user)t where flag in ('130', '131', '132', '155', '156', '185', '186')
// ============3===========电信 select count(*) from (select substr(user.phone, 1, 3) as flag from user)t where flag in ('180', '189', '133', '153')
select sum( case when flag in ('134', '135', '136', '137', '138', '139', '150', '151', '152', '157', '158', '159', '187', '188') then 1 else 0 end) as 移动, sum( case when flag in('180', '189', '133', '153') then 1 else 0 end) as 联通, sum( case when flag in('130', '131', '132', '155', '156', '185', '186') then 1 else 0 end) as 电信 from (select substr(user.phone, 1, 3) as flag from user)t