yarhsely 2013-10-08 02:21 采纳率: 0%
浏览 1093

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))

怎么能让它运行的更快一些

  • 写回答

1条回答 默认 最新

  • 软件求生 2017-11-16 09:22
    关注

    查询语句优化,万变不离其宗。
    推荐你看看这篇博文。
    http://blog.csdn.net/en_joker/article/details/78161898

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料