How do you select min date sql ?

267    Asked by DanPeters in SQL Server , Asked on Aug 29, 2023

 While trying select the min date SQL I am selecting records from a data extension that has an email address appearing more than one time but with a different date, using the below query:

It is showing the correct record, 127 records out of 403, and it is giving other columns like position, slot, and client, which I need to pull through. However, adding these to SELECT and GROUP BY clauses pulls all 403 records instead of 127. How to fix this?

Answered by Darsh K

I can see that the first SQL delivered the correct results because there is only one combination of grouping on the email address, but the second one has a grouping of four columns with 403 different combinations.

I have used the ROW_NUMBER() function to assign a number to each row and group them by email address and order by date in ascending order.

Your Answer


Parent Categories