I'm working with a database that stores records of individuals who engage with my employer for specific periods of time, and their records are updated every 10 days or so. But the database does not store their initial engagement date except in the initial record. I need to produce a table, using Microsoft Report Builder 3.0, that shows all records for a person and the initial engagement date.
Here's a sample of what my simple SELECT queries return. (And they really are simple queries--SELECT about six fields FROM one table WHERE one condition is true.)
Customer ID | Session Date | Record Created Date |
---|---|---|
5678 | 4/1/2019 | 4/4/2019 |
5678 | 4/1/2019 | 4/24/2019 |
5678 | 4/1/2019 | 5/5/2019 |
5678 | 4/1/2019 | 5/25/2019 |
5678 | 4/1/2019 | 6/6/2019 |
5678 | 4/1/2019 | 6/26/2019 |
5678 | 10/8/2020 | 10/10/2020 |
5678 | 10/8/2020 | 10/30/2020 |
5678 | 10/8/2020 | 11/21/2020 |
5678 | 10/8/2020 | 12/01/2020 |
54321 | 7/7/2020 | 7/9/2020 |
54321 | 7/7/2020 | 7/29/2020 |
54321 | 7/7/2020 | 8/8/2020 |
54321 | 7/7/2020 | 8/28/2020 |
54321 | 7/7/2020 | 9/7/2020 |
54321 | 7/7/2020 | 9/27/2020 |
Here's a sample of what I want the results to look like.
Customer ID | Session Date | Record Created Date | Min Created | Max Created |
---|---|---|---|---|
5678 | 4/1/2019 | 4/4/2019 | 4/4/2019 | 6/26/2019 |
5678 | 4/1/2019 | 4/24/2019 | 4/4/2019 | 6/26/2019 |
5678 | 4/1/2019 | 5/5/2019 | 4/4/2019 | 6/26/2019 |
5678 | 4/1/2019 | 5/25/2019 | 4/4/2019 | 6/26/2019 |
5678 | 4/1/2019 | 6/6/2019 | 4/4/2019 | 6/26/2019 |
5678 | 4/1/2019 | 6/26/2019 | 4/4/2019 | 6/26/2019 |
5678 | 10/8/2020 | 10/10/2020 | 10/10/2020 | 12/01/2020 |
5678 | 10/8/2020 | 10/30/2020 | 10/10/2020 | 12/01/2020 |
5678 | 10/8/2020 | 11/21/2020 | 10/10/2020 | 12/01/2020 |
5678 | 10/8/2020 | 12/01/2020 | 10/10/2020 | 12/01/2020 |
54321 | 7/7/2020 | 7/9/2020 | 7/9/2020 | 9/27/2020 |
54321 | 7/7/2020 | 7/29/2020 | 7/9/2020 | 9/27/2020 |
54321 | 7/7/2020 | 8/8/2020 | 7/9/2020 | 9/27/2020 |
54321 | 7/7/2020 | 8/28/2020 | 7/9/2020 | 9/27/2020 |
54321 | 7/7/2020 | 9/7/2020 | 7/9/2020 | 9/27/2020 |
54321 | 7/7/2020 | 9/27/2020 | 7/9/2020 | 9/27/2020 |
I was able to achieve this goal in Business Objects by using a Variable that concatenated the Customer ID and Session Date fields, then adding two more Variables with these expressions:
=Min([Submitted Date]) In ([ConcatenateCustomerSession])
=Max([Submitted Date]) In ([ConcatenateCustomerSession])
Any ideas? I'd prefer to do this as a calculated field if I can, just because I'm more comfortable with expressions than with SQL code, but at this point, I'll take whatever gets the job done.
This is simple to do inside the SQL. To your existing select statement add your two other columns
,Min([Record Created Date]) Over (Partition by [Customer ID]) as [Min Created]
,Max([Record Created Date]) Over (Partition by [Customer ID]) as [Max Created]