Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1759096
  • 博文数量: 323
  • 博客积分: 5970
  • 博客等级: 大校
  • 技术积分: 2764
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-03 23:13
文章分类

全部博文(323)

文章存档

2018年(2)

2017年(11)

2016年(10)

2015年(27)

2014年(2)

2013年(30)

2012年(197)

2011年(44)

分类: Oracle

2012-05-14 10:00:18

sql语句:
select median(fee_sum_before), avg(fee_sum_before),max(...), min(...)
  from ta_user_property
 
先把这些中位数,取出来。然后再填到语句里面,否则效率也低。顺便把平均数这些也取了。填到一张表里面

--select median (fee_sum_before)  from
 
用上面的语句取数据型变量的中位数
 
case when fee_sum_before >  median (fee_sum_before) then 1 else 0 end  xxx
 
 
select xxx, cust_status, count(*) from user_property.txt t
group by xxx, cust_status
 ====================================================
sql示例:select   case when fee_sum_before >  437 then 1 else 0 end  xxx,
         cust_status,
         count(*)
from     xxx
group by case when fee_sum_before >  437 then 1 else 0 end,
         cust_status;
 
上面的437就是用median(fee_sum_before)取出来的中位数的值。
==================================================
 
Row #xxxcust_statusExpr1002占比
1104019383%
21139558%
31240748%
420158980%
5211699%
62222111%

=======
其中,占比指在当前cust_status下,该数值列中位于中位数之上或之下的用户数占该数值列所有用户数的百分比。
阅读(8054) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~