olgavillamizar
asked on
select last date from table
Hi!
I have a table with this fields: id, date and user
I want to do something like that
Select id_plano, max(date), user from table where id = 'x'
but it doesnt work
Somebody could help me?
I have a table with this fields: id, date and user
I want to do something like that
Select id_plano, max(date), user from table where id = 'x'
but it doesnt work
Somebody could help me?
Select id_plano, max(date), user from table where id = 'x' group by id_plano
What result do you want to see? Do you want the max date for that user?
id_plano is not in the list of columns you gave:
do you mean:
Select id AS id_plano, max(date), user from table where id = 'x' GROUP BY id, user
do you mean:
Select id AS id_plano, max(date), user from table where id = 'x' GROUP BY id, user
ASKER
Sorry the correct select is:
Select id, max(date), user from table where id = 'x'
I try
Select id, max(date), user from table where id = 'x'
group by id, user
But it doesnt work because I obtanin this values
id user date
X pepe 6/6/2005
X ana 3/6/2006
X pedro 6/6/2006
I want to obtain just
X pedro 6/6/2006
because is the max date to this id
Select id, max(date), user from table where id = 'x'
I try
Select id, max(date), user from table where id = 'x'
group by id, user
But it doesnt work because I obtanin this values
id user date
X pepe 6/6/2005
X ana 3/6/2006
X pedro 6/6/2006
I want to obtain just
X pedro 6/6/2006
because is the max date to this id
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, I misread pepe's year. But the scenatio still holds if you have two users with the highest date value for that ID.
ASKER
Thank you
It works.
It works.