(select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt 
from  SCP_CheckAccount  group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120)) 
as b left outer join SCP_BOSSUser as a 
on
a.operid = b.hangoprcode and cnt>49 and a.deptname not in('广州公司业务支持中心运营管理室','客户服务(广州)中心综援室')
and a.rolename is not null消息 156,级别 15,状态 1,第 3 行
关键字 'as' 附近有语法错误。

解决方案 »

  1.   

    SELECT  hangoprcode ,
            acctid ,
            convert(nvarchar(10), hangtime, 120) AS date ,
            count(1) AS cnt
    FROM    SCP_CheckAccount AS b
            LEFT OUTER JOIN SCP_BOSSUser AS a ON a.operid = b.hangoprcode
                                                 AND cnt > 49
                                                 AND a.deptname NOT IN (
                                                 '广州公司业务支持中心运营管理室',
                                                 '客户服务(广州)中心综援室' )
                                                 AND a.rolename IS NOT NULL
    GROUP BY hangoprcode ,
            acctid ,
            convert(nvarchar(10), hangtime, 120)  
      

  2.   

    select * from
    (select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt  
    from SCP_CheckAccount group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120))  
    as b left outer join SCP_BOSSUser as a  
    on
    a.operid = b.hangoprcode and cnt>49 and a.deptname not in('广州公司业务支持中心运营管理室','客户服务(广州)中心综援室')
    and a.rolename is not null
      

  3.   

    (select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt  
    from SCP_CheckAccount group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120))  
    as b这么写相当于把括号里的select查询的结果集作为一个表,但是最外边又没有select .. from ..  
      

  4.   

    select * from (select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt  
    from SCP_CheckAccount group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120))  
    as b left outer join SCP_BOSSUser as a  
    on
    a.operid = b.hangoprcode and cnt>49 and a.deptname not in('广州公司业务支持中心运营管理室','客户服务(广州)中心综援室')
    and a.rolename is not null
      

  5.   


    convert(nvarchar(10),hangtime,120))
    后面多了个括号.
      

  6.   

    SELECT  *
    FROM    ( SELECT    hangoprcode ,
                        acctid ,
                        CONVERT(NVARCHAR(10), hangtime, 120) AS date ,
                        COUNT(1) AS cnt
              FROM      SCP_CheckAccount
              GROUP BY  hangoprcode ,
                        acctid ,
                        CONVERT(NVARCHAR(10), hangtime, 120)
            ) AS b
            LEFT OUTER JOIN SCP_BOSSUser AS a ON a.operid = b.hangoprcode
                                                 AND cnt > 49
                                                 AND a.deptname NOT IN (
                                                 '广州公司业务支持中心运营管理室',
                                                 '客户服务(广州)中心综援室' )
                                                 AND a.rolename IS NOT NULL
      

  7.   

    or :
    select * from (select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt  
    from SCP_CheckAccount group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120))  
    as b left outer join SCP_BOSSUser as a  
    on a.operid = b.hangoprcode 
    where cnt>49 and a.deptname not in('广州公司业务支持中心运营管理室','客户服务(广州)中心综援室')
    and a.rolename is not null
      

  8.   


    select b.* 
    from
    (select hangoprcode,acctid,convert(nvarchar(10),hangtime,120) as date,count(1) as cnt  
    from SCP_CheckAccount group by hangoprcode,acctid,convert(nvarchar(10),hangtime,120))  
    as b left outer join SCP_BOSSUser as a  
    on
    a.operid = b.hangoprcode and cnt>49 and a.deptname not in('广州公司业务支持中心运营管理室','客户服务(广州)中心综援室')
    and a.rolename is not null