Hi,
I have a question that many of you must have come across some time.
I have at table that contains an id, date and some other columns not relevant to the question.
What I want is to get the row with the latest date. It's easy to get the max(date) just by:
select max(date)
from table
but if I want to get the id for that table, how do I do that?
I know I can do this:
select id
from table
where date = (select max(date)
from table)
but as I have quite many more tables in this select that I have to join it seems that the select will be very time-consuming if I have to have a subselect that has the same tables and joins that I have in the main select.
All suggestions are welcome!
/PeJo
I have a question that many of you must have come across some time.
I have at table that contains an id, date and some other columns not relevant to the question.
What I want is to get the row with the latest date. It's easy to get the max(date) just by:
select max(date)
from table
but if I want to get the id for that table, how do I do that?
I know I can do this:
select id
from table
where date = (select max(date)
from table)
but as I have quite many more tables in this select that I have to join it seems that the select will be very time-consuming if I have to have a subselect that has the same tables and joins that I have in the main select.
All suggestions are welcome!
/PeJo