解决方案 »
- 请假一下,window下oracle10.2.0.3或是10.2.0.2的补丁怎么打??
- app_folder.define_folder_block 的问题
- 多表查询sql问题
- 请教高手帮忙:系统升级,旧系统中的数据导入到新的系统中(表结够有改变),有什么好的解决办法????
- 有oracle入门级的经典的电子书籍吗?
- 日期值班表数据库字段该如何设计
- 高手帮个忙吧~~~~
- 求助指导写一个oracle存储过程
- 没人能详细解决OracleOraHome81ManagementServer启动时的两个错误!!!
- 给位没事请帮我看看这个 sql语句 怎么写?
- 修改表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