首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教这个是哪里格式不对

2013-01-12 
请问这个是哪里格式不对?select ISNULL(totaltime.totaltime,0)/ISNULL(totalcount.totalcount,1)from (se

请问这个是哪里格式不对?
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


               ), 0)
        / ISNULL(( 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
                 ), 1)

热点排行