应如何写SQL语句
a表
select name pay from a
aa 1
bb 4
aa 3
cc 6
nn 9
gg 5
查询第三行和第四行(或指定的其他行),结果为
aa 3
cc 6
a表
select name pay from a
aa 1
bb 4
aa 3
cc 6
nn 9
gg 5
查询第三行和第四行(或指定的其他行),结果为
aa 3
cc 6
解决方案 »
- 100分求日文版SQL SERVER 2000或SQL SERVER 2005
- 关于分组的疑难
- 一個棘手的查詢問題,請高手進
- 菜鸟请教:设@a='name',如何用@a代替select name from Table1中的"name"???我试过select @a from Table1不行
- SQL DTS从Oracle中导数据遇到的问题
- 從別的電腦導入excel出錯
- 简单的SQL语句,在线等。
- 将datetime类型变成varchar后,日期全变成了sep 5 1999之类的,如何变回1999-09-09?
- 请教:应该如何使用MS-SQL的字符串函数?
- 如何把“ ' ”添加进数据库
- [急问...]从两张数据表中抽取个别列,查询后组合成一张新表,如何做?
- 如何修改生产的xml文件格式?
select * from # where tid=3
drop table #
select * from # where tid=3 --6或其他
drop table #
--> (让你望见影子的墙)生成测试数据,时间:2008-12-13
if not object_id('tb') is null
drop table tb
Go
Create table tb([name] nvarchar(2),[tid] int)
Insert tb
select N'aa',1 union all
select N'bb',4 union all
select N'aa',3 union all
select N'cc',6 union all
select N'nn',9 union all
select N'gg',5
Go
Select * from tbselect tid=identity(int,1,1),* into # from aselect name ,tid from # where id between 3 and 4
declare @a table (sn nvarchar(10),id int)
insert into @a select 'aa',1
union all select 'bb',4
union all select 'aa',3
union all select 'cc',6
union all select 'nn',9
union all select 'gg',5
select sn,id from (
select row_number()over(order by sn) as 序号 ,* from @a
) a where 序号 in(2,4)
aa 3
cc 6