oracle sql to take the first record in a group by clause

oracle

Solution

I think an aggregate function on created date will do the trick?

select ID, max(Created_DT) from table group by ID

Problem

I have a table that has 2 columns. ID number Created_DT date I can have duplicate values in ID (and often do). I need to get just 1 record per ID and I need the Created_DT so I do: ``` select ID, Created_DT from table group by ID, Created_DT ``` However, the Created_DT has time in it as well and for the same ID can span over 2 seconds making it unique and returning 2 records instead of 1. This is such a small difference that I don't care about it. I would want to just get the first one if this happens. Doing any sort of to_char() doesn't work as I would want the actual time. I tried to_char() on the group_by Created_DT only it doesn't run. Any ideas on how I can accomplish this?

Original source