Mysql 从数据表中为组数据选择最小最大值

Mysql 从数据表中为组数据选择最小最大值,mysql,Mysql,嗨,我有这样的数据表 nickname date is_unique test 01-01-2016 yes test 01-02-2016 yes test 01-03-2016 yes test1 01-01-2016 yes test1 01-02-2016 yes test1 01-03-2016 yes 我尝试将数据分组以显示如下数据 nickname startda

嗨,我有这样的数据表

nickname  date         is_unique
test      01-01-2016   yes 
test      01-02-2016   yes 
test      01-03-2016   yes  
test1     01-01-2016   yes 
test1     01-02-2016   yes 
test1     01-03-2016   yes    
我尝试将数据分组以显示如下数据

nickname  startdate    enddate        is_unique
test      01-01-2016   01-03-2016     yes 
test1     01-01-2016   01-03-2016     yes 
但当我使用查询代码min max时,它只显示1列数据是“test”,而不显示“test1”的数据 这是我的sqlquery命令

SELECT b.nickname, min(a.date), max(a.date), a.is_unique 
FROM `table1` a 
join `table2` b 
on b.fingerid = a.acno
where a.is_unique = 1

只需在查询中添加
groupby b.nickname
,如下所示

  SELECT b.nickname, min(a.date), max(a.date), a.is_unique 
        FROM `table1` a 
        join `table2` b 
        on b.fingerid = a.acno
        where a.is_unique = 1
        GROUP BY b.nickname

只需在查询中添加
groupby b.nickname
,如下所示

  SELECT b.nickname, min(a.date), max(a.date), a.is_unique 
        FROM `table1` a 
        join `table2` b 
        on b.fingerid = a.acno
        where a.is_unique = 1
        GROUP BY b.nickname