sql - Group by clause - output is not as expected -
below sql query list of dates table.
select t2.counter_date mydates 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 solution:
select min(t1.counter_date) olddate,max(t1.counter_date) latestdate table1 t1;
in following demo can see query giving correct results. problem must in data.
edit: after edit clear problem is. once perform following query:
select min(date), max(date) tab group date
than min(date)
has equal max(date)
since there 1 date in group.
Comments
Post a Comment