I have a table like this:
PROFILE_ID X_START_DATE X_END_DATE FORMER_EMPLOYER NEW_EMPLOYER START_DATE
1 2015-07-20 2016-07-20 GOOGLE BURGER KING 2017-01-01
1 2003-10-25 2009-01-14 FACEBOOK BURGER KING 2017-01-01
2 2007-10-04 2008-05-05 MICHAELS KFC 2017-01-01
2 2008-05-06 2009-05-05 GOOGLE KFC 2017-01-01
2 2009-05-06 2010-05-05 FACEBOOK KFC 2017-01-01
3 2007-10-04 2008-05-05 MCDONALDS BURGER KING 2017-01-01
What I want:
For each PROFILE_ID, I need the row, that contains the latest X_END_DATE. For PROFILE_ID 1 I need row 1 and so on.
When I do:
Select profile_id, max(end_date)
group by 1;
I actually get what I want, but not all columns that I need. By taking more columns, I need to use them in my "groupby" statement, which is not what I want.
Thanks!!