update tablea a set a.sfyx=1 where exists(select 1 from tablea b where a.ywbh=b.ywbh group by b.ywbh having max(b.FWBH)=a.FWBH);update tablea a set a.sfyx=1 where not exists(select 1 from tablea b where a.ywbh=b.ywbh and b.FWBH>a.FWBH);
--这样试试 update tablename t set fwbh=1 where exists(select 1 from (select ywbh,max(fwbh) maxfwbh from tablename group by ywbh) tt where t.ywbh=tt.ywbh and t.fwbh=tt.maxfwbh)
update tablea a set a.sfyx=1 where not exists(select 1 from tablea b where a.ywbh=b.ywbh and b.FWBH>a.FWBH);
--试试: update tab a set sfyx=1 where ywbh='指定的值' and not exists(select 1 from tab where a.ywbh=ywbh and a.fwbh<fwbh)
UPDATE A t SET sfyx = 1 WHERE EXISTS( SELECT 1 FROM ( SELECT ywbh,MAX(fwbh) maxfwbh FROM A GROUP BY ywbh) tt ) WHERE t.ywbh=tt.ywbh AND t.fwbh = tt.maxfwbh ) or UPDATE A t SET sfyx = 1 WHERE NOT EXISTS( SELECT 1 FROM A tt WHERE tt.ywbh = t.ywbh AND tt.fwbh > t.fwbh );
UPDATE A t SET sfyx = 1 WHERE NOT EXISTS(SELECT * FROM A WHERE t.ywbh=wybh AND t.fwbh<fwbh) ;
--既然是指定的 就in update tb a set sfyx=1 where FWBH in(select max(FWBH) from tb b where ywbh=指定的 and a.ywbh=b.ywbh)
where exists(select 1 from tablea b where a.ywbh=b.ywbh group by b.ywbh having max(b.FWBH)=a.FWBH);update tablea a set a.sfyx=1
where not exists(select 1 from tablea b where a.ywbh=b.ywbh and b.FWBH>a.FWBH);
update tablename t
set fwbh=1
where exists(select 1 from
(select ywbh,max(fwbh) maxfwbh
from tablename group by ywbh) tt
where t.ywbh=tt.ywbh and t.fwbh=tt.maxfwbh)
where not exists(select 1 from tablea b where a.ywbh=b.ywbh and b.FWBH>a.FWBH);
update tab a set sfyx=1 where ywbh='指定的值'
and not exists(select 1 from tab where a.ywbh=ywbh and a.fwbh<fwbh)
SET sfyx = 1
WHERE EXISTS(
SELECT 1 FROM (
SELECT ywbh,MAX(fwbh) maxfwbh
FROM A GROUP BY ywbh) tt
)
WHERE t.ywbh=tt.ywbh AND t.fwbh = tt.maxfwbh
) or
UPDATE A t
SET sfyx = 1
WHERE NOT EXISTS(
SELECT 1 FROM A tt WHERE tt.ywbh = t.ywbh AND tt.fwbh > t.fwbh
);
UPDATE A t
SET sfyx = 1
WHERE NOT EXISTS(SELECT * FROM A WHERE t.ywbh=wybh AND t.fwbh<fwbh) ;
update tb a set sfyx=1
where FWBH in(select max(FWBH) from tb b where ywbh=指定的 and a.ywbh=b.ywbh)