我有一个查询
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,我希望它有一列用于min和max,所以欲望输出应该看起来像
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