I have this table:
As you can see in the image, there are multiple dates for each record. I want to create an extra column with the minimum date for each record. I know how to do it in python but not how to do it in sql. How can I do that?
I have this table:
As you can see in the image, there are multiple dates for each record. I want to create an extra column with the minimum date for each record. I know how to do it in python but not how to do it in sql. How can I do that?
You can use a window function:
select a.*,min(a.date1) Over(Partition by a.record1) as min_date
from table_name a
This will add a column with the mininum date at a record level. Hope this helps.