sqlserver创建视图

 

1

create view storeDifferentiation(requestid,lcbh,sqr,unfinished,finished) as  select b.requestid,b.lcbh,b.sqr,b.unfinished,a.finished

from(select h.requestid,h.lcbh,h.sqr,(count(d.mdbm)) as finished from formtable_main_586 h,formtable_main_586_dt2 d,workflow_requestbase w where h.id=d.mainid and d.xfrq is not null and w.requestid= h.requestid and w.currentnodetype = '3' group by  h.requestid,h.lcbh,h.sqr)a

     full join

    (select h.requestid,h.lcbh,h.sqr,(count(d.mdbm)) as unfinished from formtable_main_586 h,formtable_main_586_dt2 d,workflow_requestbase w where h.id=d.mainid and d.xfrq is null and w.requestid= h.requestid and w.currentnodetype = '3' group by  h.requestid,h.lcbh,h.sqr)b

    on a.requestid=b.requestid

 

 

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页