Mysql
 SQL >> Database >  >> RDS >> Mysql

Raggruppare per il tempo massimo in MySQL

Se usi USING in un inner join, le colonne devono avere lo stesso nome in entrambe le tabelle. Se maxdate non esiste nella tabella Content, l’errore nasce da lì.

SELECT func_id, checksum
FROM Content cnt
INNER JOIN (
  SELECT func_id, MAX(timestamp) AS maxdate
  FROM Content
  GROUP BY func_id
) AS max
  ON cnt.func_id = max.func_id
 AND max.maxdate = cnt.timestamp;