sql语句问题 求大神帮忙
CREATE or REPLACE view view_REPORTVIEWER_count_type as --创建视图view_REPORTVIEWER_count_type
select y_num_e,m_num_e,d_num_e,m_num_s,y_num_zf,m_num_zf,r_title from
(
--年-完成
select distinct a.r_title,b.rdlc_num y_num_e,null m_num_e,null d_num_e,null m_num_s,null y_num_zf,null m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'yyyy')=to_char(sysdate,'yyyy') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='完成'
union all
--月-完成
select distinct a.r_title,null y_num_e,b.rdlc_num m_num_e,null d_num_e,null m_num_s,null y_num_zf,null m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'mm')=to_char(sysdate,'mm') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='完成'
union all
--日-完成
select distinct a.r_title,null y_num_e,null m_num_e,b.rdlc_num d_num_e,null m_num_s,null y_num_zf,null m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'dd')=to_char(sysdate,'dd') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='完成'
union all
--作业中
select distinct a.r_title,null y_num_e,null m_num_e,null d_num_e,b.rdlc_num m_num_s,null y_num_zf,null m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'mm')=to_char(sysdate,'mm') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='申请'
union all
--年-作废
select distinct a.r_title,null y_num_e,null m_num_e,null d_num_e,null m_num_s,b.rdlc_num y_num_zf,null m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'yyyy')=to_char(sysdate,'yyyy') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='作废'
union all
--月-作废
select distinct a.r_title,null y_num_e,null m_num_e,null d_num_e,null m_num_s,null y_num_zf,b.rdlc_num m_num_zf
from REPORTVIEWER a
inner join
(select sum(rdlc_num) as rdlc_num,rdlc_id,user_id from REPORTVIEWER_count d
where to_char(d.create_date,'mm')=to_char(sysdate,'mm') group by rdlc_id,user_id) b
on b.rdlc_id=a.sid
inner join s_hse_ticket e on e.reghumsid=b.user_id
where e.erifystate='作废'
)
如上 六条select的联合 不同的只有where内的条件 现在想问问能不能在视图外查询时对视图内的时间where 条件做更改?
[解决办法]
那就不用做视力呀,.net直接拼接SQL语句完成,这样是不是就简单多了呢?
[解决办法]