Setting Up the Environment
To understand How to List the Last 25% Rows in a Result Set in SQL we need a table on which we will perform various operations and queries. Here we will consider a table called w3wiki as shown below:
Create Table:
CREATE TABLE w3wiki(
id int PRIMARY KEY,
name varchar(100),
course varchar(100)
);
Insert Values:
INSERT INTO w3wiki(id,name,course)
VALUES(1,'Vishu','Python');
INSERT INTO w3wiki(id,name,course)
VALUES(2,'Sumit','Java');
INSERT INTO w3wiki(id,name,course)
VALUES(3,'Vivek','C++');
INSERT INTO w3wiki(id,name,course)
VALUES(4,'Neeraj','Java');
INSERT INTO w3wiki(id,name,course)
VALUES(5,'Aayush','Python');
INSERT INTO w3wiki(id,name,course)
VALUES(6,'Harsh','C++');
INSERT INTO w3wiki(id,name,course)
VALUES(7,'Rahul','Python');
List the Last 25% Rows in a Result Set
Listing the last 25% of rows is a common query that we generally use to detect the recent trend in our data. Fetching the last 25% of rows will give us a brief insight into the most recent trend in our data. In some of the cases, where the data set is too large, analyzing the last 25% rows will help us in quick analytics or reporting.
In this article, we will learn about How to List the Last 25% Rows in a Result Set in SQL with the various methods and examples in detail.