So, I have a table with several entries of my users and I need to group by their ID's and retrieve the last register in the table.
To optimize my job, I have created a view using the query with a SELECT inside another for order by timestamp descendant, but it fails. I think it cannot build by views or already have a solution?
Please, if anyone know how can I do this, share!
Thanks!
P.S.: Sorry, here is the code:
SELECT 
    dg_users.id,
    dg_users.email,
    dg_maps.id,
    dg_maps.latitude,
    dg_maps.longitude,
    dg_maps.timestamp
FROM
    (SELECT 
        *
    FROM
        dg_maps
    ORDER BY dg_maps.timestamp DESC) dg_maps
JOIN
    dg_geologs ON dg_geologs.map_id = dg_maps.id
JOIN
    dg_users ON dg_users.id = dg_geologs.user_id
GROUP BY dg_geologs.user_id;
 
     
    