1,原表信息
select * from T1;
id datavalue
------ -----------
1 80
1 90
2 76
2 89
3 100
3 200
2,使用with rollup
SELECT id,MAX(datavalue),MIN(datavalue)
FROM T1 GROUP BY id WITH ROLLUP
id max(datavalue) min(datavalue)
------ -------------- ----------------
1 90 80
2 89 76
3 200 100
(NULL) 200 76