I have a table with structure:
id(INT PK), title(VARCHAR), date(DATE)
How do I select all distinct titles with their earliest date?
Apparently, SELECT DISTINCT title, MIN(date) FROM table
doesn't work.
You need to use GROUP BY
instead of DISTINCT
if you want to use aggregation functions.
SELECT title, MIN(date)
FROM table
GROUP BY title
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