日期:2014-05-18  浏览次数:20526 次

SQL语句精减
语句精减,语句如下:

update   kq_result   set   G_qkcs=(select   count(*)   from   kq_result   G,Kq_SourceQk   k   where   k.qktype= '深圳人 '   and   G.empid=k.empid   and   G.fdate=DATEADD(day,DATEDIFF(day,0,(k.fdatetime)),0))   from   kq_result   g,Kq_SourceQk   k   where   k.qktype= '深圳人 '   and   g.empid=k.empid   and   g.fdate=DATEADD(day,DATEDIFF(day,0,(k.fdatetime)),0)

共计304个字符,因特殊需要需将语句字符数量控制在249个字符以下。请大伙帮忙~~

------解决方案--------------------
update G set G_qkcs=k.cn from kq_result G,(Select empid,fdatetime,count(*) cn from Kq_SourceQk where qktype= '深圳人 ' group by empid,fdatetime) k where G.empid=k.empid and Datediff(day,g.fdate,k.fdatetime)=0