I’m trying to make a SELECT with a table which could contain more values with the same id_type like in this example:
table_intensity
id id_type value user_id creation_date
1 1 90.4 73 2010-11-06 16:27:32
2 4 1258 27 2010-11-06 16:27:48 <= up-to-date id_type
3 3 1.9 73 2010-11-06 16:31:02 <= up-to-date id_type
4 1 88.8 12 2010-11-06 16:33:11
5 1 89.1 12 2010-11-06 16:58:20 <= up-to-date id_type
How can I get the most up-to-date of every id_type? I thought something like this but dosen’t work:
SELECT * FROM table_intensity GROUP BY id_type ORDER BY id_type, creation_date
This to get a result like:
table_intensity
id id_type value user_id creation_date
2 4 1258 27 2010-11-06 16:27:48
3 3 1.9 73 2010-11-06 16:31:02
5 1 89.1 12 2010-11-06 16:58:20
If i get your question correctly, this might work for what you want to do.
You can now use the
idcolumn if that is the PK to join to the result of the below query.