I am using Microsoft Access 2010 and I have a table T_Offers
that looks like this:
Key ID Date Name Text
--- -- ---------- ----------- -----------
1 10 10/10/2015 Lorem Consectetur
2 10 10/10/2015 Ipsum Amet
3 11 27/09/2014 Dolor Sit
4 13 12/11/2013 Sit Dolor
5 14 11/07/2015 Amet Ipsum
6 14 12/07/2015 Consectetur Lorem
I need to get only one row of each ID (the one with the smallest date), so, for example, the result of this table would be:
Key ID Date Name Text
--- -- ---------- ----------- -----------
1 10 10/10/2015 Lorem Consectetur
3 11 27/09/2014 Dolor Sit
4 13 12/11/2013 Sit Dolor
5 14 11/07/2015 Amet Ipsum
This is one of the queries i've tried:
SELECT ID, name, text, MIN (date) AS minDate
FROM (SELECT ID, name, text, date
FROM T_Offers
GROUP BY ID, name, text, date
ORDER BY ID asc) as X
GROUP BY ID, name, text
This would work fine, but there's a little problem: if 2 offers with the same ID have the same date, the result table would duplicate ID, and i don't want that to happen. Is there an alternative to this problem?