I've built a query (in Oracle) that selects any row with the max date out of duplicated rows. I based my query on the one presented here, which uses a nested grouping:
SELECT *
FROM (
SELECT Train, MAX(Time) as MaxTime
FROM TrainTable
GROUP BY Train
) r
INNER JOIN TrainTable t
ON t.Train = r.Train AND t.Time = r.MaxTime
Now, since that query doesn't account for duplicated values in Time
(as commented there), I'd like to take the first record out of each "duplicated" grouped record, and to still be able to use select *
.
How can I do it?
(P.S. I tried using the other solution (using over (partition ...)
), but it didn't work, and I'd need to figure it out)