Puoi fare anche così:

"SELECT offercat, MAX(id) FROM mercatino Where immagine is Not Null GROUP BY offercat ORDER BY 2 DESC ", Conn