0

I have this table:

enter image description here

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?

Taazar
  • 1,545
  • 18
  • 27
havaey
  • 9
  • 1
  • 5

1 Answers1

2

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.

CR7SMS
  • 2,520
  • 1
  • 5
  • 13