hello,
I am sorry if this is too obvious, but I am just starting at SQL.
I have a table with fields ID, NAME, QTY and DATE_MOD. ID is an
autoincrement field and unique index, and DATE_MOD is the date of record
modification. For any NAME I can have differents QTY values, and records can
be added on different dates. I need to list just the record for each NAME
having the last DATE_MOD added to table (only one record for each date).
DATE_MOD must be obviously the max(DATE_MOD). I have tried
SELECT * FROM DB GROUP BY NAME HAVING DATE_MOD = max(DATE_MOD);
but this lists only the record having DATE_MOD=max(DATE_MOD), and
SELECT ID,NAME,QTY,max(DATE_MOD) AS DATE FROM DB GROUP BY NAME;
but it seems this one does not work neither.
It should be pretty simple and obvious (I am sure it is), but I just don't
get it! Any advice greatly appreciated!
Thanks IA
Juan