I have a query, which Join few tables and give the below result:
Id
|
Project_Id
|
Rev_Id
|
Date
|
Version
|
1
|
P12
|
ABC1001
|
2-Aug-2016
|
V12.0.10
|
1
|
P12
|
ABC1002
|
12-April-2016
|
V12.0.10
|
1
|
P12
|
ABC1003
|
12-April-2016
|
V12.0.10
|
2
|
P15
|
ABC1004
|
1-July-2016
|
V12.0.3
|
3
|
P19
|
ABC1005
|
8-Aug-2016
|
V12.0.4
|
3
|
P19
|
ABC1006
|
13-July-2016
|
V12.0.4
|
NOTE: Like above records, I have many more records in the table where only Rev_Id is unique for each row.
Requirement: I want to fetch records for each row based on Latest Date, i.e., fetch all the rows that has unique "Version" column with Latest date.. so that I get below result:
Id
|
Project_Id
|
Rev_Id
|
Date
|
Version
|
1
|
P12
|
ABC1001
|
2-Aug-2016
|
V12.0.10
|
2
|
P15
|
ABC1004
|
1-July-2016
|
V12.0.3
|
3
|
P19
|
ABC1005
|
8-Aug-2016
|
V12.0.4
|
For above result, I tried using below query in existing query:
Where Date = (select max(Date) from Table)
But unable to get the desired result. Please help me how to achieve the result.
NOTE: I am using Oracle DB.