select count(e.log_id) from eshop_login_log e where to_char(e.login_time,'yyyy-MM-dd')>'2009-09-10'
union all
select count(distinct t.ip) from eshop_url_access_log tunion all
--通用积分兑换次数和兑换的总积分数
select count(oi.order_item_id) from eshop_order_item oi where oi.integral_type=0
union all
--通用积分兑换的总积分数
select sum(oi.integral) from eshop_order_item oi where oi.integral_type=0
union all
--特定积分兑换的积分总数
select sum(oia.integral) from eshop_order_item oia where oia.integral_type=1
union all
--特定积分兑换次数和兑换的总积分数
select count(oia.order_item_id) from eshop_order_item oia where oia.integral_type=1
union all
--订单总数
select sum(o.order_id) from eshop_order o
union all
--商品兑换数
select sum(oip.order_sum) from eshop_order_item oip
输出结果为:
10
1
18
711
0
559
37
但是我要求结果输出为:10 1 18 711 0 559 37
请问各位大侠们,怎么做啊
select 1 id, count(e.log_id) c1 from eshop_login_log e where to_char(e.login_time,'yyyy-MM-dd')>'2009-09-10' group by 1
full join
select 1 id, count(distinct t.ip) c2 from eshop_url_access_log t group by 1
on e.id = t.id
full join
select 1 id
count(case when oi.integral_type=0 then oi.order_item_id end) c3,
sum(case when oi.integral_type=0 then oi.integral end) c4,
sum(case when oi.integral_type=1 then oi.integral end) c5,
count(case when oi.integral_type=1 then oi.order_item_id end) c6,
select sum(o.order_id) c7 from eshop_order,
sum(oi.order_sum) c8
from eshop_order_item oi group by 1
on t.id = oi.id);试试,没测试
少了,
select sum( case when t.c1=1 then t.c2 else 0 end) aa,
sum( case when t.c1=2 then t.c2 else 0 end) bb,
sum( case when t.c1=3 then t.c2 else 0 end) cc,
sum( case when t.c1=4 then t.c2 else 0 end) dd,
sum( case when t.c1=5 then t.c2 else 0 end) ee,
sum( case when t.c1=6 then t.c2 else 0 end) ff,
sum( case when t.c1=7 then t.c2 else 0 end) gg,
sum( case when t.c1=8 then t.c2 else 0 end) hh
from(
select 1 c1 ,count(e.log_id) c2 from eshop_login_log e where to_char(e.login_time,'yyyy-MM-dd')>'2009-09-10'
union all
select 2 c1 , count(distinct t.ip) c2 from eshop_url_access_log t
union all
--通用积分兑换次数和兑换的总积分数
select 3 c1 , count(oi.order_item_id) c2 from eshop_order_item oi where oi.integral_type=0
union all
--通用积分兑换的总积分数
select 4 c1 , sum(oi.integral) c2 from eshop_order_item oi where oi.integral_type=0
union all
--特定积分兑换的积分总数
select 5 c1 , sum(oia.integral) c2 from eshop_order_item oia where oia.integral_type=1
union all
--特定积分兑换次数和兑换的总积分数
select 6 c1 , count(oia.order_item_id) c2 from eshop_order_item oia where oia.integral_type=1
union all
--订单总数
select 7 c1 , sum(o.order_id) c2 from eshop_order o
union all
--商品兑换数
select 8 c1 , sum(oip.order_sum) c2 from eshop_order_item oip
) t;
(select count(distinct t.ip)"2" from eshop_url_access_log t ),
(select count(decode(integral_type,0,order_item_id))"3",
sum(decode(integral_type,0,integral))"4",
sum(decode(integral_type,1,integral))"5",
count(decode(integral_type,1,order_item_id))"6"
from eshop_order_item),
(select sum(o.order_id) "7" from eshop_order o ),
(select sum(oip.order_sum)"8" from eshop_order_item oip)