SSRS and ignored "having" clause

Viewed 125

I'm trying to get a list of data whose last update date is older than the current date minus x month.

As an example, here is a sample table :

|  DataGUID  |  UpdateDate   |
|------------|---------------|
|    AAA     |   12-05-2017  |
|    BBB     |   22-06-2017  |
|    AAA     |   14-02-2017  |
|    BBB     |   16-05-2017  |

Currently, I have a SQL request looking somewhat like the following :

SELECT
      DataGUID,
      MAX(UpdateDate)
FROM
      Table
GROUP BY
      DataGUID
HAVING
      MAX(UpdateDate) <= DATEADD(mm, CAST('-'+@LastUpdatedXMonthAgo AS INT), GETDATE())
ORDER BY
      MAX(UpdateDate) DESC;

Expected result is the following (with @LastUpdatedXMonthAgo = 1, and current date 13-07-2017) :

|  DataGUID  |  UpdateDate   |
|------------|---------------|
|    AAA     |   12-05-2017  |

It works on SSMS, but SSRS seems to ignore the "having" clause, and gives me this result :

|  DataGUID  |  UpdateDate   |
|------------|---------------|
|    BBB     |   22-06-2017  |
|    AAA     |   12-05-2017  |

Seem like SSRS just ignore the "having" clause, is there a way to make it work without using SSRS filters?

1 Answers
Related