日期:2014-05-18 浏览次数:20448 次
SELECT * FROM TB T1 WHERE EXISTS( SELECT 1 FROM TB T2 WHERE T2.VID=T1.VID AND T2.VNAME=T1.VNAME AND T2.TID<T1.TID ) AND EXISTS( SELECT 1 FROM TB T2 WHERE T2.VID=T1.VID AND T2.VNAME=T1.VNAME AND T2.TID>T1.TID )
------解决方案--------------------
SELECT * FROM TB t WHERE TID != ( SELECT MIN(Tid) FROM TB WHERE Vid = t.VID AND [VName] = t.[VName] ) AND Tid != ( SELECT MAX(Tid) FROM TB WHERE Vid = t.VID AND [VName] = t.[VName] )
------解决方案--------------------
SELECT * FROM TB t WHERE EXISTS ( SELECT 1 FROM TB WHERE T.TID>MIN(TID) AND T.TID<MAX(T.TID) AND Vid = t.VID AND [VName] = t.[VName] GROUP BY VNAME,VID)
------解决方案--------------------
select * from(select px=row_number()over(partition by VID ,VName order by TID,* from tb)t where px<>1 union all select * from(select px=row_number()over(partition by VID ,VName order by TID desc),* from tb)t where px<>1