create or replace view view_jyxkz_tj as
--yxq为有效期,ZXRQ为注销时间,FZRQ为发证日期
select t.dqxx_id,decode(t.yxq,‘‘,‘0001-01-01‘,t.yxq) as yxq, decode(t.zxrq,‘‘,‘0001‘,to_char
(t.zxrq,‘yyyy‘))
as zxrq,decode(t.fzrq,‘‘,‘0001‘,to_char(t.fzrq,‘yyyy‘)) as fzrq
from zm_busi_jyxkz_apply t;
====================================================================================
select AB.DQXX_ID ,AB.CZNUM,AB.XFNUM,C.ZXNUM
from (
select decode(A.DQXX_ID,‘‘,B.DQXX_ID,A.DQXX_ID) as DQXX_ID ,A.CZNUM,B.XFNUM
from (
select DQXX_ID,count(*) as CZNUM from
view_jyxkz_tj t
where t.fzrq<‘2013‘ and t.yxq>‘2013-01-01‘ and dqxx_id is not null
group by dqxx_id ) A
full join
(
select DQXX_ID,count(*) as XFNUM from
view_jyxkz_tj t
where t.fzrq=‘2012‘ and dqxx_id is not null
group by dqxx_id ) B
on A.DQXX_ID=B.DQXX_ID
) AB
full join
(
select DQXX_ID,count(*) as ZXNUM from
view_jyxkz_tj t
where t.zxrq=‘2012‘ and dqxx_id is not null
group by dqxx_id ) C
on AB.DQXX_ID=C.DQXX_ID
相关文章
- 03-28join,left join,inner join,full join的区别?
- 03-28最新电Call记录统计-full hash join用法
- 03-28split和join的用法
- 03-28一文彻底了解join的各种用法
- 03-28一张图看懂 SQL语句的各种JOIN 用法(超级实用)
- 03-28os.path.abspath ,os.path.join() os.path.dirname ()3个函数的用法
- 03-28左连接(left join) ,右连接(right join ),内连接(inner join)和全外连接(full join)的区别
- 03-28数据库表的连接(Left join , Right Join, Inner Join)用法详解
- 03-28os.path.abspath(__file__)&os.path.dirname()&os.path.basename(__file__)&os.path.join()的用法详解
- 03-28SQL中 Left Join 与 Right Join 与 Inner Join 与 Full Join的区别