PERCENT
PERCENT is an SQL keyword used in the SELECT TOP clause. It allows the retrieval of a specific percentage of rows from a query result. It enables data filtering to achieve more efficient and relevant result sets.
Example
Output
Explanation
The example uses the PERCENT_RANK() function in Oracle SQL to calculate the percentile rank of each employee’s salary compared to all other salaries in the ‘EMPLOYEES’ table. The PERCENT_RANK() function computes the relative rank of a row returned by a query in the form of a percentage between 0 and 1. The highest salary has a percent rank of 0, and all other salaries are ranked accordingly.
Example
Output
Explanation
The SQL code showcases the PERCENT
keyword’s function. It retrieves the top 10 percent of records from the Products
table, ordering them by ProductName
. The returned records are a subset, making up 10 percent of the total number, determined based on the specified ProductName
ordering.