select table1.*, firstime,lastime from
(select cardno,min(date) firstime,max(date) lastime
from table1
group by cardno)t
where t.cardno=cardno and (消费日期=t.firstime or 消费日期=t.lastime)
select cardno,date from table1 where date=max(date) or date=min(date)
select cardno,firsttime=min(date),lasttime=max(date)
from table1
group by cardno
这样吗
select cardno , max(date),min(date) from table1 group by cardno