--如果 Field_B 不能做主键,可以这样写
select * from 表A a
where not exists(
select * from 表A
where Field_A=a.Field_A
and(
Field_B<a.Field_B
--Field_B相同时,取id最大的
or Field_B=a.Field_B and id<a.id))
--下面的也是应该是不存在于小于当前记录,如果用大于前记录那应该是exists.是这样的吧!
--如果 Field_B 不能做主键
select * from 表A a
where not exists(
select * from 表A
where Field_A=a.Field_A and Field_B<a.Field_B)
and id=(
select max(id) from 表A where Field_B=a.Field_B and Field_A=a.Field_A)
--如果 Field_B 不能做主键
select * from 表A a
where not exists(
select * from 表A
where Field_A=a.Field_A and Field_B<a.Field_B)
and id=(
select max(id) from 表A where Field_B=a.Field_B and Field_A=a.Field_A)
--写反了,最迟是最小的
select * from 表A a
where not exists( --不存在Field_A与当前相同,Field_B 比当前记录更小的记录就行了
select * from 表A where Field_A=a.Field_A and Field_B<a.Field_B)
--如果 Field_B 不能做主键,可以这样写
select * from 表A a
where not exists(
select * from 表A
where Field_A=a.Field_A
and(
Field_B<a.Field_B
--Field_B相同时,取id最大的
or Field_B=a.Field_B and id<a.id))