Reputation: 37
Below is my sql query to get the list of dates from a table.
select t2.counter_date as myDates from table1 t1;
output:
myDates
2014-03-14 00:00:00
2014-05-11 00:00:00
2014-11-03 00:00:00
2014-12-23 00:00:00
2015-01-12 00:00:00
2015-08-08 00:00:00
2016-03-14 00:00:00
2017-03-14 00:00:00
2017-03-19 00:00:00
Below is the solution:
select min(t1.counter_date) as oldDate,max(t1.counter_date) as latestDate from table1 t1;
Upvotes: 0
Views: 50
Reputation: 10701
In the following demo you can see that your query is giving the correct results. The problem must be in your data.
EDIT: after the edit it is clear where the problem is. Once you perform the following query:
SELECT min(date), max(date)
FROM tab
GROUP BY date
than min(date)
has to be equal to max(date)
since there is just one date in the group.
Upvotes: 1