我有个问题
select
title, id, min(sleep) as min_sleep, max(sleep) as max_sleep
from
myTable
group by
title, id
我得到的结果是这样的
title id min_sleep max_sleep
Sheep 123 11/05/2014 18:03 11/05/2014 18:03
Sheep 444 11/05/2014 12:23 11/05/2014 12:23
Sheep 444 11/06/2014 12:00 11/06/2014 12:00
Sheep 444 11/05/2014 17:23 11/05/2014 17:23
Sheep 444 12/31/2014 19:55 12/31/2014 19:55
对于每个唯一的id,我希望它有一列表示最小值和最大值,因此期望输出应该如下所示
title id min_sleep max_sleep
sheep 123 11/05/2014 18:03 11/05/2014 18:03
Sheep 444 11/05/2014 12:23 12/31/2014 19:55
暂无答案!
目前还没有任何答案,快来回答吧!