I am attempting to extract data from a database that has an error in it. I can't resolve the error (it's a "design feature"), so i have to try to query around it. Here's how it is stored.
Record ID | Create Date | Update Date | Record Status
123 | 05/01/2018 | 05/01/2018 | Active
123 | 05/08/2018 | 05/08/2018 | Active
123 | 05/15/2018 | 05/15/2018 | Closed
123 | 05/22/2018 | 05/22/2018 | Closed
456 | 06/02/2018 | 06/02/2018 | Pending
456 | 06/09/2018 | 06/09/2018 | Active
456 | 06/16/2018 | 06/16/2018 | Active
456 | 06/23/2018 | 06/23/2018 | Suspended
And so on. As you can see, the Create Date and Update Date values match on each row. The Create Date value is supposed to be the date the Record ID was initially created, but it's actually being captured as the date the Record ID update was created.
What I need is a report that brings me a single row per Record ID that shows me the minimum Create Date and the maximum Update Date, so that the result looks something like this:
Record ID | Create Date | Update Date | Record Status
123 | 05/01/2018 | 05/22/2018 | Closed
456 | 06/02/2018 | 06/23/2018 | Suspended
I've tried using the MIN and MAX aggregate functions in the Query Designer, and that works just fine until I add any other field that may change through the life of the record. I get this:
Record ID | Create Date | Update Date | Record Status
123 | 05/01/2018 | 05/08/2018 | Active
123 | 05/15/2018 | 05/22/2018 | Closed
456 | 06/02/2018 | 06/02/2018 | Pending
456 | 06/09/2018 | 06/16/2018 | Active
456 | 06/23/2018 | 06/23/2018 | Suspended
When I use the Query Designer, the query text looks like this:
SELECT
DB.RECORD.RECORD_ID
,DB.RECORD.RECORD_STATUS_CODE
,MAX(DB.RECORD.RECORD_CREATED_DATE) AS Max_RECORD_CREATED_DATE
,MIN(DB.RECORD.RECORD_UPDATED_DATE) AS Min_RECORD_UPDATED_DATE
FROM
DB.RECORD
GROUP BY
DB.RECORD.RECORD_ID
,DB.RECORD.RECORD_STATUS_CODE
I'm relatively new to Report Builder, though I think I'm picking up its concepts quickly. What am I missing here?