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.
Advertisement
Answer
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