I have a table like the following :
ID |INFO | DATE_DT
-------------------------
1091|info5 |10/10/2010
1239|old.info |14/09/2010
1340|old.info |07/10/2010
3481|info |16/10/2010
4134|info3 |21/01/2011
i would like to display just one row with the following conditions :
– if i have in my table one row with INFO = 'info' –> display just this row
– if i dont have one row with INFO = 'info' so i –> display the row with INFO = 'old.info' and DATE_DT = MAX(DATE_DT)
so, in my example if my table is :
ID |INFO | DATE_DT
-------------------------
1091|info5 |10/10/2010
1239|old.info |14/09/2010
1340|old.info |07/10/2010
3481|info |16/10/2010 ===> display this row
4134|info3 |21/01/2011
or if my table doesnt containt INFO = ‘info’
ID |INFO | DATE_DT
-------------------------
1091|info5 |10/10/2010
1239|old.info |14/09/2010
1340|old.info |07/10/2010 ===> display this row
4134|info3 |21/01/2011
any suggestions?
Thanks.
You could select both row and take by priority the one that satisfies the first condition:
If you remove the row
'info', the row whereDATE_DT = MAX(DATE_DT)will be chosen: