SQL排名的问题,A这个人在数据库里排第十,怎么查询一个他前面两位,后面两位,包括自己的五条数据,各位有啥高招? DECLARE @table TABLE ( id INT PRIMARY KEY , ) , NAME ) ) INSERT INTO @table( NAME )VALUES ( 'AA' ) INSERT INTO @table( NAME )VALUES ( 'BB' ) INSERT INTO @table( NAME )VALUES ( 'CC' ) INSERT INT…
以下举例是查询相同数据,否则则相反 方法一: select * from A as x,B as y where x.a1=y.b1 and x.a2=y.b2 and x.a3=y.b3 方法二: select * from tb INTERSECT --UNION select * from dataname.dbo.tb…