Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the DMSQL TOP clause

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to use DMSQL TOP clauses". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

In DM, you can use the TOP clause to filter the results. The syntax is as follows:

:: = TOP

| |

< ,>

| | PERCENT |

| | WITH TIES |

| | PERCENT WITH TIES |

:: = integer (> = 0)

Parameters.

1. TOP selects the first n records of the result.

2. TOP, select the N2 record after the N1 record.

3. TOP PERCENT represents the first n% record of the selection result.

4. TOP PERCENT WITH TIES represents the first n% records of the selected result, while specifying that the result set can return additional rows. Extra rows are sorted in the same order as the last row

All rows sorted by the key. WITH TIES must appear at the same time as the ORDER BY clause, or ignore WITH TIES if there is no ORDER BY clause.

For example, look up the numbers and names of the two most expensive products at present.

SQL > SELECT TOP 2 PRODUCTID,NAME FROM PRODUCTION.PRODUCT2 ORDER BY NOWPRICE DESC;LINEID PRODUCTID NAME--1 10 crackle series (7 volumes) 26 long March used time: 2.906 (ms). Execute id is 39552.

For example, look up the number and name of the product that is the second most expensive at current price.

SQL > SELECT TOP 1 PRODUCTID,NAME FROM PRODUCTION.PRODUCT2 ORDER BY NOWPRICE DESC;LINEID PRODUCTID NAME--16 long March used time: 2.768 (ms). Execute id is 39555.

For example, look up 70% of the product number, name, and publication date of the latest publication date.

SQL > SELECT TOP 70 PERCENT WITH TIES PRODUCTID,NAME,PUBLISHTIME FROM PRODUCTION.PRODUCT ORDER BY PUBLISHTIME DESC LINEID PRODUCTID NAME PUBLISHTIME- 17 data structure (C language version) (CD attached) 2007-03-012 5 collected works of Lu Xun (novels, Prose, Essays) all two volumes 2006-09-013 6 long March 2006-09-014 3 Old people and Hai 2006-08-0158 there are no trifles in the work 2006-01-016 4 shooting Diaoying Xiong Zhuan (all four volumes) 2005-12-017 2 Water margin 2005-04-018 1 A Dream of Red Mansions 2005-04-018 rows gotused time: 1.776 (ms). Execute id is 39590. This is the end of the introduction of "how to use DMSQL TOP clauses". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report