This is my first call for help, most of the time I have been able to figure out from google searches into StackOverflow but this time I can't seem to find an answer or don't understand fully the amswers that are already out there.
I have 2 tables.
Table 1 = T1.
Columns ID1, ID2, TITLE
Value 1, D1, TITLE1
2, D2, TITLE2
3, D3, TITLE3
.....
Table 2 = T2.
Columns ID1, Rev, CODE
Value 1, 1, V1
1, 2, V2
1, 3, V3
1, 4, V4
2, 1, V5
2, 2, V6
2, 3, V7
3, 1, V8
Ideally I want to return the max value of Rev from T2, toegther with column ID2 from T1. So the results should look like this.
Columns T1.ID2, T1.TITLE, T2.REV, T2.CODE
D1, TITLE1, 4, V4
D2, TITLE2, 3, V6
D3, TITLE3, 1, V8
This is my attempt and overall I think I am on the right path but it could be some messed up syntax.
SELECT T1.ID2, T1.TITLE,
SUBSTRING(
SELECT MAX(T2.REV)
FROM T2 T2B
WHERE T2B.ID1 = T1.ID1)
AS MAXREV,
T2.CODE
FROM T1, T2
WHERE T1.ID1 = T2.ID1
ORDER BY 1, 2 DESC
Any advice would be greatly appreciated.
Cheers.