I have data like this (col2 is of type Date)
| col1 | col2 | ------------------------------ | 1 | 17/10/2007 07:19:07 | | 1 | 17/10/2007 07:18:56 | | 1 | 31/12/2070 | | 2 | 28/11/2008 15:23:14 | | 2 | 31/12/2070 |
How would select rows which col1 is distinct and the value of col2 is the greatest. Like this
| col1 | col2 | ------------------------------ | 1 | 31/12/2070 | | 2 | 31/12/2070 |
SELECT col1, MAX(col2) FROM some_table GROUP BY col1;
select col1, max(col2)
from table
group by col1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With