Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > S > SELECT

TOP

Scroll Prev Top Next More

This parameter includes the support to specify the TOP n qualifier for the SELECT command. The TOP n will retrieve the top number of records from the table.

 

SELECT_TOP

 

 

The "TOP n" goes between the word SELECT and the column list for the command.

 

n

Specifies the number of records to retrieve

 

collist

Specifies a list of one or more column names, separated by a comma (or the current delimiter)

 

Examples:

To show the top 5 bonuses where the bonus is under $500 from the SalesBonus table in the ConComp sample database:

 

SELECT TOP 5 EmpID,Bonus FROM SalesBonus WHERE Bonus < 500 ORDER BY Bonus=DESC

 

EmpID      Bonus          

---------- ---------------

       131         $456.75

       131         $326.25

       102         $175.00

       131         $157.50

       129         $153.60

 

To show the three companies with the largest purchases for the RRBYW20 sample database:

 

SELECT custid,company FROM customer WHERE custid IN +

(SELECT custid FROM invoiceheader WHERE netamount IN +

(SELECT TOP 3 netamount FROM invoiceheader))

 

custid     company                                  

---------- ----------------------------------------

       121 Bytes & Words

       124 Barton and Associates

       127 RAM Data Systems, Inc.