fetch

DB2 Using LIMIT and OFFSET - Fetch Last 10 Rows



Sharing buttons:

hello friends in this video i'm going to

discuss about

limit and offset in db2 database

so right now i'm using the viewer

enterprise

and here db2 it's the connector

and here i'm using employees table

and uh first let's see the record inside

employees tube

so this is the record and here you can

see

this all those total numbers of rows are

1.7

now idea by using

[Music]

or limit to so by using

limit to keyword so we can

do some limitation on the rows so if you

want to display

only talk by those so you can keep the

limit

so i do this also

okay so select start from

employees and here during the ordering

on

employee id and if i

include idea limit so

that display top 10 record

from the table so here you can see

one two three

so add here the limitation

on the table add him

now here after if i execute

so this is offset okay

so here if i execute

so after 5 after 5

that display 10 okay

so here you can see 1 to 10 and here

1.5 and

total 1 4 so if you got total

rows of 10 now here you can see if i

execute this one so 5

rows and 6.7 so by using offset

so after five rows itself displaying the

record

now here so select restart from

employees and

here

so this is the employee id now i do the

if i'm doing the limitation 10 to 20

so and just for 10 plus 109

now execute to this kd

so and here after one zero nine

one one zero at start from one zero

and here that in 129

so the limitation and you know that

10 to 20 so add him total numbers of

close

it's at this point 20. so it

is after 10 after that

it should explain 20 close

so by um you want to display

highest salary on the table

so here let's add secured

and over here you can see this is the

fairly column now for highest value

we must include two and here or

sadly is in descending order

now here you can see this is in

descending order

so if you want to display top 10

top 5 highest standing so you should use

limit

so you can you include the limit so add

him

from here to this point that display the

standard

law executed

so top 10 those are displaying and this

is the right side

now let's go include only

column if you want to display top file

and saturday so get the limitation

fine so here

this is the top right side and here

sign plus now saturdays and duplicate

because the employees has

17 000 or

70 000 saturday

so two different employees have 17 17

000 percent

so like this if you want to display

heart

attack

first at seventeen thousand it's the

discipline in the table

so the reason for using

limit so keep the limitation on the

close that's why

we are using it and here this is the

outside

so after when you give any value so

after

giving the value that display the rows

so if i give it here at this point

now let's execute is kitty

so after 2 so after 1.1

that is start from 1 0 2 and that

display the barrels

are executed so here

one zero two and total numbers of those

things this time now limit is 10

so total numbers of those this point

so this is the reason we are using

offset and edit

in divi two so i hope guys this video is

helpful for you so now

in this video it's over so thanks for

watching