# Paginating Query Results
__*paginating*__
__*Top-N Analysis*__
+ **`ORDER BY... LIMIT {offset}, {count}`**
+ Browse planets in descending order by name, show 3 planets at a time (for single page), for example:
```
~!@// 1st page:@!~
SELECT name, mass FROM planets ORDER BY name DESC LIMIT 0, 3;

~!@// 2nd page:@!~
SELECT name, mass FROM planets ORDER BY name DESC LIMIT 3, 3;

~!@// 3rd page:@!~
SELECT name, mass FROM planets ORDER BY name DESC LIMIT 6, 3;
```
------------------------------------------------------------

A paginating query statement needs to have a sort condition. In addition to the service sort condition, it should also include a primary key or other unique key to ensure stable paging, and to avoid unstable result sets caused by no service sort column or one service sort column value matching multiple records. If you looked closely at the execution plan on the previous page, you may have found the `offset:0, count:7`  keyword. Now you can try a few different ways to further control the LIMIT behavior to achieve the effect of paging: offset.

```
tidb> SELECT name, mass FROM planets ORDER BY name DESC LIMIT 0, 3;
+--------+------+
| name   | mass |
+--------+------+
| Venus  | 4.87 |
| Uranus | 86.8 |
| Saturn |  568 |
+--------+------+
3 rows in set (0.01 sec)

tidb> SELECT name, mass FROM planets ORDER BY name DESC LIMIT 3, 3;
+---------+-------+
| name    | mass  |
+---------+-------+
| Pluto   | 0.013 |
| Neptune |   102 |
| Mercury |  0.33 |
+---------+-------+
3 rows in set (0.00 sec)
tidb> SELECT name, mass FROM planets ORDER BY name DESC LIMIT 6;
+---------+-------+
| name    | mass  |
+---------+-------+
| Venus   |  4.87 |
| Uranus  |  86.8 |
| Saturn  |   568 |
| Pluto   | 0.013 |
| Neptune |   102 |
| Mercury |  0.33 |
+---------+-------+
6 rows in set (0.00 sec)
```
