问题描述
- sqlserver数据库怎样优化代码
-
select
c.participant_name,
c.login_id,
@year as y,
datepart(MONTH,receive_date) as m,
b.phase_name as lc,
m.manu_number as gh,
max(datediff(day, m.submit_date, a.submit_date)) as t
from manuflow a
left join review_phase b on a.phase_id=b.phase_id
left join participant c on a.submitter_id=c.participant_id,manuscript m
where
(@editor='' or c.participant_name=@editor)
and receive_date>=(@year+'-1-1') and receive_date<( cast(cast(@year as int)+1 as varchar(4))+'-1-1' )
and not c.login_id is null
and not c.participant_name is null
and a.submit_date >= (@year+'-1-1') and a.submit_date<( cast(cast(@year as int)+1 as varchar(4))+'-1-1' )
and m.submit_date >= (@year+'-1-1') and m.submit_date<( cast(cast(@year as int)+1 as varchar(4))+'-1-1' )
and m.submit_date <= a.submit_date
and b.phase_name = 'szs'
and m.manu_number in(select manu_number from #GH)
group by b.phase_name,m.manu_number,c.participant_name,c.login_id,datepart(MONTH,receive_date)
order by c.participant_name,c.login_id,datepart(MONTH,receive_date),b.phase_name,m.manu_number,max(datediff(day, m.submit_date, a.submit_date))怎么能让它运行的更快一些
时间: 2024-11-03 22:09:24