22,210
社区成员
发帖
与我相关
我的任务
分享
FIndex FID FChangeID FCloseFlag
1 100 150 0
2 100 0 0
FIndex FID FChangeID FCloseFlag
1 100 150 0
2 100 0 1
SELECT * FROM TB WHERE FClostFlag=1 and FIndex=1 or FClaseFlag=0 and FIndex=2 or FCloseFlag<>1 and FCloseFlag<>0
select *
from tb
where (FClostFlag = 1 and FIndex = 1) or (FCloseFlag = 0 and FIndex = 2)
select distinct b.* from tb a
cross apply(select top 1 * from tb where FID=a.FID order by FCloseFlag desc,FIndex desc) b