Specify the number of acquisitions as a percentage

Page updated :

If you want to get the "Top N" of the number to be retrieved, you can use the TOP clause, but you can also get this number as a percentage. Use TOP - PERCENT to get in percentage.

An example of selecting a table with 10,000 records. If you do not use the TOP clause, 10,000 are retrieved.

select * from [TST_Tag01]

TOP 句を使用しない SELECT

The following example retrieves the number specified in the TOP clause.

select top 200 * from [TST_Tag01]

TOP 句を使用した SELECT

The following example retrieves the number of percent specified in the TOP clause. You're getting 40% of the records because you've specified 40.

select top (40) percent * from [TST_Tag01]

TOP 句に PERCENT を使用した SELECT

PERCENT can also contain decimals.

select top (3.5) percent * from [TST_Tag01]

TOP 句に小数を含む PERCENT を使用した SELECT

The number that can be percent can be between 0 and 100.

Also, if you want to use PERCENT, enclose the number in parentheses (). This is for compatibility considerations, but if you don't enclose it in parentheses, you may get an error, so be sure to use parentheses.