The access paging path. The row_number () over () aggregation function is implemented in access.
Source: Internet
Author: User
The rowid pseudo column can be used for Oracle paging query. The row_number () over () aggregate function can be used for paging queries in DB2. MySQL has limit. Access seems to be inherently flawed and only provides top N. So how can we use top to implement paging query? Assume that the Access Table T1 create table T1 (TC1 varchar (50) not null primary key, Tc2 varchar (30), TC3 varchar (30) randomly inserts 20 data records. If 5 data entries are displayed on each page, how do I display 11 to 15 entries? With the Top N function, you can use the following SQL statements to complete the first 11 items. Select top 11 TC1, TC2, TC3 from T1 can also be like this: Select top 15 TC1, TC2, TC3 from T1 want to get 11 to 15, it is estimated that the difference set is generally considered, but access does not provide the difference set except T, which can be implemented using not in. Select top 15 TC1, TC2, TC3 from T1 where TC1 not in (select top 10 TC1 from T1) if it is a relatively large table, not in cannot use the index, how can we achieve extremely low efficiency? The left join can be used to solve the problem select. * From (select top15 TC1, TC2, TC3 from T1) A left join (select top 10 TC1, TC2, TC3 from T1) B on. TC1 = B. TC1 where IIF (B. TC1, '0', '1') = '1' this SQL statement has obvious advantages. It effectively utilizes the table's primary key index. Of course, because access cannot judge B. TC1 is null like this, you need to use IIF (B. TC1, '0', '1') = '1' to save the country by curve.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.