I have the following query in DB2 but is not working, the problem is the max function but I,m not sure how to fix it.
SELECT CAR.VI max(CAR.ID),
TU.SOLD
FROM P.CAR CAR, A.TU TU WHERE CAR.VI = TU.VI
'Table1' ' VI: USER: DATE: DATE2: STATUS: ID'
' 2T1BU4 DEALER 2012-10-15 2012-10-15 CER 1 '
' 2T1BU4 DEALER 2012-10-15 2012-10-15 CER 2 '
' 2T1BU3 DEALER 2012-10-15 2012-10-15 DRA 1 '
' VI: SOLD:'
' 2T1BU4 Y'
' 2T1BU3 N'
What I want to receive from my query will be something like this:
' VI: USER: DATE: DATE2: STATUS: ID SOLD'
' 2T1BU4 DEALER 2012-10-15 2012-10-15 CER 2 Y '
' 2T1BU3 DEALER 2012-10-15 2012-10-15 DRA 1 N '
I want to get the VI that have the Max ID
You didn’t provide a lot of details but I am going to take a guess that you want this:
Or you can use a sub-query: