I have a table that contains whenever an email has been open. When a user opens an email multiple times you will have rows that shared the same values except the CREATED_DATE (OPENED_DATE of an email).
TABLE 1 - OPENED_EMAILS
| CREATED_DATE | EMAIL_CODE | USER_ID | 
|---|---|---|
| 10-5-2022 | E1 | U1 | 
| 15-5-2022 | E2 | U2 | 
| 17-5-2022 | E2 | U3 | 
| 17-5-2022 | E3 | U4 | 
| 20-5-2022 | E2 | U3 | 
| 22-5-2022 | E3 | U4 | 
| 23-5-2022 | E3 | U4 | 
I would like to make a query that retrieves only the first time an email has been opened by an user (MIN_CREATED_DATE of an opened email).
Expected result:
TABLE 2 - FIRST_OPENED_EMAILS
| CREATED_DATE | EMAIL_CODE | USER_ID | 
|---|---|---|
| 10-5-2022 | E1 | U1 | 
| 15-5-2022 | E2 | U2 | 
| 17-5-2022 | E2 | U3 | 
| 17-5-2022 | E3 | U4 | 
 
     
    
