当前位置: 代码迷 >> Sql Server >> 请教这个是哪里格式不对
  详细解决方案

请教这个是哪里格式不对

热度:79   发布时间:2016-04-24 23:55:54.0
请问这个是哪里格式不对?
select ISNULL(totaltime.totaltime,0)/ISNULL(totalcount.totalcount,1) 
 from
 (select SUM(DATEDIFF(HOUR,receivedate + ' ' + receivetime,case isnull(operatedate,'')  when '' then  '2012-10-30 23:59:59' else operatedate + ' ' + operatetime end)) as totaltime 
 from View_Workflow_ActOperator as a inner join HrmResource as b on a.userid = b.id inner join workflow_nodebase as c on a.nodeid = c.id where c.isstart = 0 and c.isend = 0 and b.subcompanyid1 = 7
 )as totaltime 
 left join  
 (select count(1) as totalcount 
 from View_Workflow_ActOperator as a inner join HrmResource as b on a.userid = b.id   inner join workflow_nodebase as c on a.nodeid = c.id where c.isstart = 0 and c.isend = 0 and b.subcompanyid1 = 7
) as totalcount



总是在最后一个totalcount后面显示红色波浪线

------解决方案--------------------
把left join改成逗号
------解决方案--------------------
SELECT  ISNULL(( SELECT SUM(DATEDIFF(HOUR, receivedate + ' ' + receivetime,
                                     CASE ISNULL(operatedate, '')
                                       WHEN '' THEN '2012-10-30 23:59:59'
                                       ELSE operatedate + ' ' + operatetime
                                     END)) AS totaltime
                 FROM   View_Workflow_ActOperator AS a
                        INNER JOIN HrmResource AS b ON a.userid = b.id
                        INNER JOIN workflow_nodebase AS c ON a.nodeid = c.id
                 WHERE  c.isstart = 0
                        AND c.isend = 0
                        AND b.subcompanyid1 = 7
  相关解决方案