时间:2021-07-01 10:21:17 帮助过:130人阅读
生成的表,及表中的数据:
--方法一
select top 1 * from
(
SELECT TOP 2 *
FROM [dbo].[emp_pay]
WHERE base_pay = 500
order by employeeID ASC) as a --注意:派生表后面一定要指定别名.
order by a.employeeID DESC
--方法二
select IDENTITY(int,1,1) ID,* INTO #Temp from [dbo].[emp_pay] where base_pay = 500
select * from #Temp where ID =2
drop Table #Temp
--方法三
set rowcount 2
SELECT * into #t from [dbo].[emp_pay] where base_pay = 500
set rowcount 1
delete from #t
select * from #t
set rowcount 0
drop table #t
sql语句查询出表里符合条件的第二条记录的方法
标签:let esc creat sql delete money des pre table