suppose we've got the following table:
A B C Year
----- ---- ---- -----
ABC Val1 Val2 2015
ABC Val3 Val4 2016
ABC Val6 Val7 2017
ABC Val8 Val9 2018
XYZ Val10 Val9 2016
XYZ Val3 Val4 2017
WRD Val1 Val2 2015
WRD Va2 Val9 2017
----------------------------
As you can see the relationship between coloumns A and Year is 1:n The question: I can't figure it out, how to write a SQL query that prints out the values of the cloumns of A,B,C and D considering the following condition: if the corresponding year of the coloumn A is 2018 print that line (A,B,C,Year) other wise print the line of max(year). That means the answear should be the following:
A B C Year
----- ---- ---- -----
ABC Val8 Val9 2018
XYZ Val3 Val4 2017
WRD Va2 Val9 2017
Many thanks in advance