取出表A中第31到第40記錄 資料庫

2021-10-12 21:26:19 字數 472 閱讀 5939

寫出一條sql語句:取出表a中第31到第40記錄(sqlserver,以自動增長的id作為主鍵,注意:id可能不是連續的

a. select top 10 * from a where id not in (select top 30 id from a)

演變步驟:

1)select top 30 id from t_filterwords–取前條

2)select * from t_filterwords where id not in (select top 30 id from t_filterwords)–取id不等於前三十條

3)select top 10 * from t_filterwords

b. select top 10 * from a where id > (select max(id) from (select top 30 id from a )as a)

c. 1用row_number實現

取表中第30到第40條記錄

標實字段沒有規律 select top 10 from 飛狐工作室 where 身份證號碼 not in select top 30 身份證號碼 from 飛狐工作室 order by 身份證號碼 asc 標實字段有規律 例如 自動編號 select top 10 from 章立民研究室 where...

從Table 表中取出第 m 條到第 n 條的記錄

從table 表中取出第 m 條到第 n 條的記錄 not in 版本 select topn m 1 from table where id notin select topm 1 id from table 從table表中取出第m到n條記錄 exists版本 select topn m 1 f...

從Table 表中取出第 m 條到第 n 條的記錄

從table 表中取出第 m 條到第 n 條的記錄 從table 表中取出第 m 條到第 n 條的記錄 not in 版本 select top n m 1 from table where id not in select top m 1 id from table 從table表中取出第m到n條...