写出一条Sql语句:取出表A中第31到第40记录(SQLServer,以自动增长的ID作为主键,注意:ID可能不是连续的
展开全部
SQL语句为:
select * from A where ID >=31 and ID <= 40
ORACLE语句为:
select * from A where RowNum>=31 and RowNum<=40
ORACLE和SQL都能使用的是
select top 10 * from (select top 40 * from A order by ID) order by ID desc
或者是
select top 10 * from A where ID not in (select ID from top 30 from A)
select * from A where ID >=31 and ID <= 40
ORACLE语句为:
select * from A where RowNum>=31 and RowNum<=40
ORACLE和SQL都能使用的是
select top 10 * from (select top 40 * from A order by ID) order by ID desc
或者是
select top 10 * from A where ID not in (select ID from top 30 from A)
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql:
select top 10 * from (select top 40 * from A order by A.ID)T
order by T.ID desc
orcal:
SELECT * FROM (SELECT ROW_.*, ROWNUM ROWNUM_ FROM (
SELECT * FROM A
)ROW_ WHERE ROWNUM <=40) WHERE ROWNUM_ > 31
望采纳
select top 10 * from (select top 40 * from A order by A.ID)T
order by T.ID desc
orcal:
SELECT * FROM (SELECT ROW_.*, ROWNUM ROWNUM_ FROM (
SELECT * FROM A
)ROW_ WHERE ROWNUM <=40) WHERE ROWNUM_ > 31
望采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不好意思之前算错数,下面一句SQL代码返回第31到第40共10条记录,按自动ID升序排序:
SELECT T2.* FROM (SELECT TOP 10 T1.* FROM (SELECT TOP 40 * FROM TABLE1 ORDER BY ID)T1 ORDER BY T1.ID DESC) T2 ORDER BY T2.ID
SELECT T2.* FROM (SELECT TOP 10 T1.* FROM (SELECT TOP 40 * FROM TABLE1 ORDER BY ID)T1 ORDER BY T1.ID DESC) T2 ORDER BY T2.ID
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT TOP 10 * FROM 表名 WHERE ID NOT IN(SELECT ID FROM TOP 30 FROM 表名)
肯定可以用。。
肯定可以用。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询