I am trying to update the existing table with one more column PageNo. The PageNo is dynamic value based on the total number of rows in the table. Say for an example I have 12 rows in the table. And while sending output from SQL, the customer want to send 4 rows per each page. So in my table
- the first 4 rows will be Pageno:1.
- Second set of 4 rows will be Page no:2
and so on..
Say for an example
SET @NoRowsPerPage=4
TotalNumber of rows in the table =12
So overall I have 3 pages (12/4) = 3:
Current output is as follows:
Id | Name | Age | PageNo |
---|---|---|---|
100 | sat | 26 | NULL |
200 | Apple | 30 | NULL |
103 | CHERRY | 26 | NULL |
106 | Orange | 26 | NULL |
107 | Raspberry | 26 | NULL |
109 | Lemon | 36 | NULL |
389 | Pineapple | 28 | NULL |
107 | MITUN | 26 | NULL |
109 | TEMPOR | 26 | NULL |
389 | KISN | 26 | NULL |
110 | Mandarin | 26 | NULL |
111 | BANANAG | 26 | NULL |
Expected output:
Id | Name | Age | PageNo |
---|---|---|---|
100 | sat | 26 | 1 |
200 | Apple | 30 | 1 |
103 | CHERRY | 26 | 1 |
106 | Orange | 26 | 1 |
107 | Raspberry | 26 | 2 |
109 | Lemon | 36 | 2 |
389 | Pineapple | 28 | 2 |
107 | MITUN | 26 | 2 |
109 | TEMPOR | 26 | 3 |
389 | KISN | 26 | 3 |
110 | Mandarin | 26 | 3 |
111 | BANANAG | 26 | 3 |
Can you please help. The idea is my first select query will fetch only the pageno :1 rows. second select query will pass only pageno:2 values...