I have SQL Table with following columns:
| Key | Created_at | Acc_id |
SQL is running in ONLY_FULL_GROUP_BY mode.
Im' trying to get, for each Acc_id, the Key that has smallest Created_at. Naturally, I would write something like
SELECT Key
, MIN(Created_at)
, Acc_id
From MyTable
GROUP BY Acc_id
But query fails, because I have ONLY_FULL_GROUP_BY and it does not know which Key to choose from the groups. I want the one corresponding to MIN(Created_at) (the one from same row), but how do I tell it?
Thanks.