0

我正在尝试建立一些报告。我有这个查询:

SELECT  Agente.UserUri as Agente, COUNT(Agente.UserUri) as NumeroRisposte

FROM    Users as User1, Users as User2, Users as StartedByUser, Users as Agente,
        Phones as FromPhone, Phones as ConnectedPhone,
        SessionDetails as IVRSession, SessionDetails as AgenteSession,
        VoipDetails,
        ClientVersions as Client1Version, ClientVersions as Client2Version

WHERE   VoipDetails.SessionIdTime = IVRSession.SessionIdTime AND     
        VoipDetails.SessionIdSeq = IVRSession.SessionIdSeq AND
        VoipDetails.FromNumberId = FromPhone.PhoneId AND
        VoipDetails.FromNumberId = ConnectedPhone.PhoneId AND

        IVRSession.SessionIdTime = AgenteSession.ReplacesDialogIdTime AND    
        IVRSession.SessionIdSeq = AgenteSession.ReplacesDialogIdSeq AND
        Agente.UserId = AgenteSession.User1Id AND

        User1.UserId = IVRSession.User1Id AND
        User2.UserId = IVRSession.User2Id AND
        StartedByUser.UserId = IVRSession.SessionStartedById AND

        Client1Version.VersionId = IVRSession.User1ClientVerId AND
        Client2Version.VersionId = IVRSession.User2ClientVerId AND
        (Client1Version.ClientType = 1024 or Client2Version.ClientType = 1024) AND

        User2.UserUri = 'ivr0679071new' AND
        IVRSession.InviteTime BETWEEN '18/02/2014 16:28:19' AND '19/02/2014 16:28:19'

        GROUP BY Agente.UserUri
        ORDER BY Agente.UserUri

不要试图理解查询。

我只想知道如何使用报告参数在 BETWEEN 条件中使用它们来过滤查询。

这是可能的?

4

2 回答 2

0

我会用参数占位符(例如@StartDate 和@EndDate)替换SQL 中的两个日期字符串(例如'18/02/2014 16:28:19')。

然后我会添加两个报表参数 StartDate 和 EndDate。数据类型为日期。

于 2014-02-20T06:35:54.473 回答
0

从此更改此代码

BETWEEN '18/02/2014 16:28:19' AND '19/02/2014 16:28:19'

对此

BETWEEN @StartDate AND @EndDate

这将自动添加 2 个报告参数。

于 2014-02-20T08:43:59.023 回答