If order by is used after the top query statement, and the order by field contains duplicate values, this top will become invalid.
All records are returned.
For example, select top 5 from news order by createdate
If there are duplicate values in createdate, all records will be displayed, and this top function is invalid. However, if no duplicate value exists in createdate, the top function is still valid. Therefore, when using the top function in access, pay attention to whether the order by field has duplicate values. For example, if createdate is "year-month-day hour: minute: Second, that's basically not a problem. But for the sake of insurance, we can also use the "add primary key" method: Select top 5 from news order by createdate DESC, Id DESC
This problem can be prevented by using the primary key as a guarantee that "It cannot be repeated ".
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service