标签:dex where origin from 字段 case sum cas char
select count(1) from pd_xxx_origin_xxx_data where create_time like ‘2019-02-23%‘ and source=‘20036‘
SELECT
sum(case when create_time like ‘2019-02-23%‘ then 1 else 0 end) as inst_count,
sum(case when active_time like ‘2019-02-23%‘ then 1 else 0 end) as active_count
FROM `pd_xxx_origin_xxx_data` where charindex(‘20036‘,source );
SELECT
sum(case when create_time like ‘2019-02-23%‘ then 1 else 0 end) as inst_count,
sum(case when active_time like ‘2019-02-23%‘ then 1 else 0 end) as active_count
FROM `pd_xxx_origin_xxx_data ` where source like ‘20036%‘;
SELECT
sum(case when create_time like ‘2019-02-23%‘ then 1 else 0 end) as inst_count,
sum(case when active_time like ‘2019-02-23%‘ then 1 else 0 end) as active_count
FROM `pd_xxx_origin_xxx_data` where source=‘20052‘;
sql优化 分字段统计查询
标签:dex where origin from 字段 case sum cas char
原文地址:https://www.cnblogs.com/yuzhould/p/11844613.html