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" ,
casewhencount(*)=0then'N'--不读回报 没有未完成的委托else'Y'--有未完成的委托end"qbh"--取回报fromacc_seat a, acc_holder2seat b , acc_holder c ,dl_entrust d
wherea.exchgcode_=v_exchgcode
anda.seatid_=v_seatid
anda.exchgcode_=b.exchgcode_
anda.seatid_=b.seatid_
andb.exchgcode_=c.exchgcode_
andb.holderacc_=c.holderacc_
andd.exchgcode_=a.exchgcode_
andd.seatid_=a.seatid_
andd.holderacc_=b.holderacc_
andd.entstatus_notin(3,6)
groupbya.seatid_ ,--席位b.exchgcode_ ,--交易所b.holderacc_ ,--客户号c.password_ ;--密码
select a.seatid_ "xwh" ,--席位b.exchgcode_ "jys" ,--交易所b.holderacc_ "khh",--客户号c.password_ "khmm" ,--密码nvl( (
selectcount(*)
fromdl_entrust d
where1=1andd.exchgcode_=a.exchgcode_
andd.seatid_=a.seatid_
andd.holderacc_=b.holderacc_
andd.entstatus_notin(3,6)
),0) "num"
fromacc_seat a, acc_holder2seat b , acc_holder c
wherea.exchgcode_=&v_exchgcode
anda.seatid_=&v_seatid
anda.exchgcode_=b.exchgcode_
anda.seatid_=b.seatid_
andb.exchgcode_=c.exchgcode_
andb.holderacc_=c.holderacc_