ID相同,值也相同的情况:
select sum(field2) from(select distinct id,field2 from 表) a
ID相同,值不一定相同:
--取值最大的一笔
select sum(field2) from(select id,field2=max(field2) from 表 group by id) a
--取值最小的一笔
select sum(field2) from(select id,field2=min(field2) from 表 group by id) a
ID相同,值也相同的情况:
select sum(field2) from(select distinct id,field2 from 表) a
ID相同,值不一定相同:
--取值最大的一笔
select sum(field2) from(select id,field2=max(field2) from 表 group by id) a
--取值最小的一笔
select sum(field2) from(select id,field2=min(field2) from 表 group by id) a