解决方案 »
- 请大家帮忙推荐一下 经典的oracle学习书籍 谢谢!
- oracle odi 在使用代理的时候报如下异常,求解
- 如何用POWER DESIGNER来从SQL2008(2000)导出表到ORACLE中?
- 根据年份-> 取每个月的总额
- 请教大家一个SQL语句!!!!!!!!
- 如何知道.dmp文件的oracle版本
- 如何才能学好ORACLE
- 将oracle中表结构导出成图片格式的工具
- 我装了9i,可以在服务器用sqlplus可能连上,但在其它机子就安不上了,我在用jbuilder的连接工具就能连,这是为什么啊,我怎么才能用其它工
- The NetWork Adapter could not establish the connection错误!请大神指点
- 修改表cjb下的cj 的值为50~59随机整数的 oracle 命令 谢谢大牛
- dataguard中standby库上这两种模式有何区别?
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了
行转列不太知道思路,
所以我这样做 ,计算百分比好长我这样,
select
m.servicetype 服务类别,
--来源1
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end) 建单量 ,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end) 成交量,
round(decode(
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end),'0','0', --分母是否为 0
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') --计算成交率
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end)/
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end)
)*100,2) 成交率,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then m.charge else '0' end) 成交金额 ,
--来源2
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end) 建单量 ,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end) 成交量,
round(decode(
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end),'0','0', --分母是否为 0
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') --计算成交率
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end)/
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end)
)*100,2) 成交率,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then m.charge else '0' end) 成交金额
from t_Order_List m
where m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
or m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
group by m.service_type_second_id
那其实结果是这样的:12号成交的不管是什么时候建单的都要统计到建单量里面,但是12号建单的但不是12号成交的就不统计到成交量里面
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了那其实结果是这样的:12号成交的不管是什么时候建单的都要统计到建单量里面,但是12号建单的但不是12号成交的就不统计到成交量里面
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了那其实结果是这样的:12号成交的不管是什么时候建单的都要统计到建单量里面,但是12号建单的但不是12号成交的就不统计到成交量里面
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了行转列不太知道思路,
所以我这样做 ,计算百分比好长我这样,再计算百分比时有什么好的做法吗?
select
m.servicetype 服务类别,
--来源1
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end) 建单量 ,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end) 成交量,
round(decode(
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end),'0','0', --分母是否为 0
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') --计算成交率
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end)/
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end)
)*100,2) 成交率,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then m.charge else '0' end) 成交金额 ,
是这样吧?
是这样的 哪天建单建单量就算在你那天。哪天成交的成交量就算在那天。
比如 统计12号的数据。 11号建的单,但在12号成交。那么这单的建单量属于11号。但他的属于12好的成交量。
这就是那种12号这项服务有成交量而没有建单量情况,因为他的建单时间在11号。(表达不是很清晰,不知道您能否理解)select a.servicetype,
a.ordersource,
sum(case
when (a.create_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss')) or
(a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') and
a.create_time <
to_date('2015-01-12', 'yyyy-mm-dd')) then
1
else
0
end) create_num,
sum(case when a.deal_time between to_date('2015-01-12', 'yyyy-mm-dd') and
to_date('2015-01-12 23:59:59', 'yyyy-mm-dd hh24:mi:ss') then 1 else 0 end) deal_num
from t_order a
group by a.servicetype,
a.ordersource;
你看看是这个意思吧?如果是的的话再做一次行列转换就可以了 --来源2
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end) 建单量 ,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end) 成交量,
round(decode(
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end),'0','0', --分母是否为 0
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') --计算成交率
and m.order_source = '1' and m.deal_state='1' then 1 else 0 end)/
sum( case when m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd') and m.order_source = '1' then 1 else 0 end)
)*100,2) 成交率,
sum( case when m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
and m.order_source = '1' and m.deal_state='1' then m.charge else '0' end) 成交金额
from t_Order_List m
where m.create_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
or m.deal_time between trunc(sysdate-3,'dd') and trunc(sysdate,'dd')
group by m.service_type_second_id