count(distinct xxx) 与distinct ; count(case when )
2013-05-02 09:30
399 查看
select a,b,c
select a,b,distinct c 不对 distinct必须是对所有字段排重,必须写在外面。
select distinct a,b,c
第二种 也叫转置 主要理解意思
select a,count(distinct b) ....group by a
按照a,汇总不同的b。
1 1
1 2
1 3
1 2
汇总后:
1 3
count(distinct case when time_measure = '>1' then ISR else null end) 去排重 汇总
sum(case when time_measure = '>1' then 1 else 0 end ) 汇总不排重
select a,b,distinct c 不对 distinct必须是对所有字段排重,必须写在外面。
select distinct a,b,c
第二种 也叫转置 主要理解意思
select a,count(distinct b) ....group by a
按照a,汇总不同的b。
1 1
1 2
1 3
1 2
汇总后:
1 3
count(distinct case when time_measure = '>1' then ISR else null end) 去排重 汇总
sum(case when time_measure = '>1' then 1 else 0 end ) 汇总不排重
相关文章推荐
- 字段转置count(distinct xxx) 与distinct
- spark【例子】count(distinct 字段) 简易版 使用groupByKey和zip
- [转]LINQ语句之Select/Distinct和Count/Sum/Min/Max/Avg
- [MongoDB]count,gourp,distinct
- error MSB3027: Could not copy "xxx.dll" to "xxx.dll". Exceeded retry count of 10. Failed.
- count(distinct user_id)
- count distinct
- 文章标题SELECT sum(ord.order_price) as order_total_price, count(distinct ord.user_id) as user_total_num
- Mysql中count(*),DISTINCT的使用方法和效率研究
- MySQL中distinct和count(*)的使用方法比较
- Mysql中count(*),DISTINCT的使用方法和效率研究
- C++中使用Mongo执行count和distinct运算
- Hive SQL优化之 Count Distinct
- 关于sql sum,case when.....end , count 的应用
- python pandas 实现SQl的count(*),count(distinct **)
- mysql count distinct null 使用注意事项
- 查询所有订单的最新信息的SQL语句的写法 DISTINCT配合count和group by一起完成
- Query Performance regarding DISTINCT COUNT Measure
- LINQ体验——LINQ语句之Select/Distinct和Count/Sum/Min/Max/Avg
- hibernate 中的count和distinct同时使用