sql Where with max(timestamp)

Asked

Viewed 103 times

0

I want to find the id of the most recent match in relation to and date, like "timestamp".

I used the command:

select partida_id from partida
where 'data' = max('data');

But of error:

SQL Error [1111] [HY000]: Invalid use of group Function

What I have to change to make it work.

2 answers

0

The most effective way to get the id of the latest match is this:

select partida_id from partida
order by 'data' desc limit 1

0


If there may be multiple departures on that date use:

SELECT partida_id FROM partida
WHERE data = (SELECT max(data) FROM partida);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.