select x.id,x.sum-y.sum margin from
(
select a.id,a.sum from t_table a,
(
select id,max(time) time from t_table group by id
) b
where a.id=b.id and a.time=b.time
) x,
(
select a.id,a.sum from t_table a,
(
select id,min(time) time from t_table group by id
) b
where a.id=b.id and a.time=b.time
) y
where x.id=y.id;
(
select a.id,a.sum from t_table a,
(
select id,max(time) time from t_table group by id
) b
where a.id=b.id and a.time=b.time
) x,
(
select a.id,a.sum from t_table a,
(
select id,min(time) time from t_table group by id
) b
where a.id=b.id and a.time=b.time
) y
where x.id=y.id;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货