本文介绍了如何在不使用order_number()和不使用row_number()的情况下选择sql server中的第n行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好, 任何人都可以告诉我如何在不使用row_number()的情况下选择sql server 中的 nth 行/ b>和不使用order by。 也不使用游标。(游标可以是解决方案之一,但是当有lacs时它会降低性能记录。) 提前感谢...
解决方案从TableName中选择* ColumnName =(从TableName中选择MAX(ColumnName))
选择第n行不使用rwo_number()&命令和光标: 这里用顶部'n'代替前5名 声明 @ NewId bigint , @ NewFname varchar ( 20 ), @ NewLname varchar ( 20 ), @ NewSalary money select top 5 @ NewId = eid, @ NewFname = fname @NewLname = lname,@ NewSalary = salary from Tbl_Emp_Detail 选择 @ NewId , @ NewFname , @ NewLname , @ NewSalary
声明 @ NewId bigint 选择 top 5 @ NewId = eid 来自 Tbl_Emp_Deatail 选择 * 来自 Tbl_Emp_Detail 其中 eid = @ NewId
Hi there, Can anybody tell me how to select nth row in sql server without using row_number() and without using order by. Also without using cursors.(cursor can be one of the solution, but it decreases the performance when there are lacs of records.) thanks in advance...
解决方案 Select * From TableName Where ColumnName = (Select MAX(ColumnName) From TableName)To select the nth row without using rwo_number()& order by and cursor : Here replace top 5 by top 'n' declare @NewId bigint,@NewFname varchar(20),@NewLname varchar(20),@NewSalary money select top 5 @NewId =eid,@NewFname = fname @NewLname=lname,@NewSalary=salary from Tbl_Emp_Detail select @NewId ,@NewFname,@NewLname,@NewSalaryOR
declare @NewId bigint select top 5 @NewId=eid from Tbl_Emp_Deatail select * from Tbl_Emp_Detail where eid=@NewId更多推荐
如何在不使用order
发布评论