oracle
insert table1
select name ,count(*)
from ...
group by type
select ,case type1 == value1 , case type2 == value2 , case type3 = value3 .........这里也要写死的
from table2 , table1
导入到临时表 1:N 然后拼接出一张表 写1次固定代码
还没想到更好的...................????????
其他方式
select ......
from a
( select * ,count from ... where type1 ) t1
( select * ,count from ... where type2 ) t2
.
.
.
.
有几种就要写几种.... 但是速度如何呢? 要发动N次的 index count(*) 写2次固定代码
1-1-1-N
可能因为 不是3,6 整天记录都不输出 问题是怎么解决 .
select
a.seatid_ "xwh" , --席位
b.exchgcode_ "jys" , --交易所
b.holderacc_ "khh", --客户号
c.password_ "khmm" , -- 密码
count(*) "num" ,
case
when count(*) = 0 then 'N' --不读回报 没有未完成的委托
else 'Y' -- 有未完成的委托
end "qbh" -- 取回报
from acc_seat a, acc_holder2seat b , acc_holder c ,dl_entrust d
where a.exchgcode_ = v_exchgcode
and a.seatid_ = v_seatid
and a.exchgcode_ = b.exchgcode_
and a.seatid_ = b.seatid_
and b.exchgcode_ =c.exchgcode_
and b.holderacc_ =c.holderacc_
and d.exchgcode_ = a.exchgcode_
and d.seatid_ = a.seatid_
and d.holderacc_ = b.holderacc_
and d.entstatus_ not in (3,6)
group by a.seatid_ , --席位
b.exchgcode_ , --交易所
b.holderacc_ , --客户号
c.password_ ; -- 密码
select
a.seatid_ "xwh" , --席位
b.exchgcode_ "jys" , --交易所
b.holderacc_ "khh", --客户号
c.password_ "khmm" , -- 密码
nvl( (
select count(*)
from dl_entrust d
where 1=1 and d.exchgcode_ = a.exchgcode_
and d.seatid_ = a.seatid_
and d.holderacc_ = b.holderacc_
and d.entstatus_ not in (3,6)
),0 ) "num"
from acc_seat a, acc_holder2seat b , acc_holder c
where a.exchgcode_ = &v_exchgcode
and a.seatid_ = &v_seatid
and a.exchgcode_ = b.exchgcode_
and a.seatid_ = b.seatid_
and b.exchgcode_ =c.exchgcode_
and b.holderacc_ =c.holderacc_