附近有语法错误

SET @L_SQL2 = N'
   SELECT  DeptID, DeptName, AdminUserId, AdminUserName, AssignCount, TraceCount, UserIntention1, UserIntention2, UserIntention3, UserIntention4, UserIntention5, UserIntention6, UserIntention7
   FROM (
    SELECT
    Z3.DeptId AS DeptID,  Z6.DeptName AS DeptName,
    Z3.AdminUserId AS AdminUserId, Z7.UserName AS AdminUserName,
    Z4.AssignCount AS AssignCount,
    Z5.TraceCount AS TraceCount,
    Z3.UserIntention1 AS [UserIntention1],
    Z3.UserIntention2 AS [UserIntention2],
    Z3.UserIntention3 AS [UserIntention3],
    Z3.UserIntention4 AS [UserIntention4],
    Z3.UserIntention5 AS [UserIntention5],
    Z3.UserIntention6 AS [UserIntention6],  
    Z3.UserIntention7 AS [UserIntention7]  
    FROM ' +
    '##TempUserIntention AS Z3 ' + CHAR(13) +
    '    LEFT JOIN(
       SELECT ZZ4.AssignCount, ZZ4.[AdminUserId]
       FROM (
         SELECT COUNT(DISTINCT [UserId]) AS AssignCount, [AdminUserId]
         FROM [DbCRM].[dbo].[tblUserInfo]
         GROUP BY [AdminUserId]
        ) AS ZZ4
       ) AS Z4 ON( Z4.[ADMINUSERID] = Z3.[ADMINUSERID])' + CHAR(13) +
    '    LEFT JOIN( 
       SELECT ZZ5.TraceCount, ZZ5.[AdminUserId]
       FROM (
         SELECT COUNT(DISTINCT [UserId]) AS TraceCount, [AdminUserId]
         FROM [DbCRM].[dbo].[tblUserInfoRemarks]
         GROUP BY [AdminUserId]
        )AS ZZ5
       ) AS Z5 ON ( Z5.[ADMINUSERID] = Z3.[ADMINUSERID])' + CHAR(13) +
    '    LEFT JOIN [dbo].[tblSysDept] AS Z6 ON( Z3.[DeptId] = Z6.[DeptId])' + CHAR(13) +
    '    LEFT JOIN [dbo].[vw_UserInfo] AS Z7 ON( Z3.[AdminUserId] = Z7.[Id])' + CHAR(13) +
    '    WHERE Z3.[UID] >=' + CAST(@P_STARTINDEX AS VARCHAR(10)) + 
    ' AND  Z3.[UID] <= '+ CAST(@P_EndIndex AS VARCHAR(10)) +  CHAR(13) +
    '    ) AS YY'; --一定要有别名YY,否则报')' 附近有语法错误。
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值