Assume that I have a database with the columns foo, bar, creationdate and data.
What I need, is a query, that queries the the first row that was created (i.e. where creationdate is the lowest) for each unique combination of foo and bar.
For example, for the following rows:
+-----+-----+--------------+----------------+
| foo | bar | creationdate | data |
+-----+-----+--------------+----------------+
| abc | def | 31.12.2019 | some data |
+-----+-----+--------------+----------------+
| abc | def | 01.05.2020 | other data |
+-----+-----+--------------+----------------+
| ghi | jkl | 04.05.2020 | more data |
+-----+-----+--------------+----------------+
| ghi | jkl | 05.05.2020 | even more data |
+-----+-----+--------------+----------------+
Then the desired output is:
+-----+-----+--------------+----------------+
| abc | def | 31.12.2019 | some data |
+-----+-----+--------------+----------------+
| ghi | jkl | 04.05.2020 | more data |
+-----+-----+--------------+----------------+
What would be the SQL query that would give me the desired result? I am using Postgres.