Limit Data Selections Using LIMIT, ROWNUM

4 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€85.14
List Price:  €119.21
You save:  €34.06
£74.68
List Price:  £104.56
You save:  £29.87
CA$137.64
List Price:  CA$192.70
You save:  CA$55.06
A$150.39
List Price:  A$210.55
You save:  A$60.16
S$128.91
List Price:  S$180.48
You save:  S$51.56
HK$778.15
List Price:  HK$1,089.44
You save:  HK$311.29
CHF 79.60
List Price:  CHF 111.44
You save:  CHF 31.84
NOK kr1,012.71
List Price:  NOK kr1,417.84
You save:  NOK kr405.12
DKK kr636.06
List Price:  DKK kr890.52
You save:  DKK kr254.45
NZ$172.81
List Price:  NZ$241.94
You save:  NZ$69.13
د.إ367.21
List Price:  د.إ514.11
You save:  د.إ146.90
৳12,214.34
List Price:  ৳17,100.57
You save:  ৳4,886.22
₹9,071.34
List Price:  ₹12,700.24
You save:  ₹3,628.90
RM409.20
List Price:  RM572.90
You save:  RM163.70
₦145,133.48
List Price:  ₦203,192.68
You save:  ₦58,059.20
₨28,011.26
List Price:  ₨39,216.89
You save:  ₨11,205.62
฿3,142.13
List Price:  ฿4,399.11
You save:  ฿1,256.98
₺4,269.71
List Price:  ₺5,977.76
You save:  ₺1,708.05
B$541.91
List Price:  B$758.70
You save:  B$216.78
R1,681.81
List Price:  R2,354.61
You save:  R672.79
Лв166.53
List Price:  Лв233.15
You save:  Лв66.62
₩146,386.44
List Price:  ₩204,946.87
You save:  ₩58,560.43
₪321.04
List Price:  ₪449.47
You save:  ₪128.43
₱5,894.51
List Price:  ₱8,252.55
You save:  ₱2,358.04
¥15,495.23
List Price:  ¥21,693.94
You save:  ¥6,198.71
MX$1,797.13
List Price:  MX$2,516.05
You save:  MX$718.92
QR364.26
List Price:  QR509.98
You save:  QR145.72
P1,324.33
List Price:  P1,854.12
You save:  P529.78
KSh12,892.71
List Price:  KSh18,050.31
You save:  KSh5,157.60
E£4,748.49
List Price:  E£6,648.08
You save:  E£1,899.58
ብር15,617.37
List Price:  ብር21,864.95
You save:  ብር6,247.57
Kz91,205.27
List Price:  Kz127,691.03
You save:  Kz36,485.76
CLP$91,340.86
List Price:  CLP$127,880.86
You save:  CLP$36,540
CN¥704.64
List Price:  CN¥986.53
You save:  CN¥281.88
RD$6,354.07
List Price:  RD$8,895.96
You save:  RD$2,541.88
DA12,968.25
List Price:  DA18,156.07
You save:  DA5,187.81
FJ$225.35
List Price:  FJ$315.50
You save:  FJ$90.15
Q765.53
List Price:  Q1,071.77
You save:  Q306.24
GY$20,910.39
List Price:  GY$29,275.38
You save:  GY$8,364.99
ISK kr12,635.73
List Price:  ISK kr17,690.53
You save:  ISK kr5,054.80
DH919.51
List Price:  DH1,287.35
You save:  DH367.84
L1,689.61
List Price:  L2,365.52
You save:  L675.91
ден5,241.56
List Price:  ден7,338.40
You save:  ден2,096.83
MOP$801.46
List Price:  MOP$1,122.07
You save:  MOP$320.61
N$1,686.27
List Price:  N$2,360.84
You save:  N$674.57
C$3,678.63
List Price:  C$5,150.23
You save:  C$1,471.59
रु14,462.40
List Price:  रु20,247.95
You save:  रु5,785.54
S/336.50
List Price:  S/471.12
You save:  S/134.61
K430.77
List Price:  K603.10
You save:  K172.32
SAR375.15
List Price:  SAR525.23
You save:  SAR150.07
ZK2,306.35
List Price:  ZK3,228.98
You save:  ZK922.63
L433.42
List Price:  L606.81
You save:  L173.38
Kč2,067.88
List Price:  Kč2,895.12
You save:  Kč827.23
Ft32,789.63
List Price:  Ft45,906.80
You save:  Ft13,117.16
SEK kr928.77
List Price:  SEK kr1,300.32
You save:  SEK kr371.54
ARS$144,063.05
List Price:  ARS$201,694.03
You save:  ARS$57,630.98
Bs690.62
List Price:  Bs966.89
You save:  Bs276.27
COP$380,273.94
List Price:  COP$532,398.74
You save:  COP$152,124.79
₡49,997.35
List Price:  ₡69,998.29
You save:  ₡20,000.94
L2,631.45
List Price:  L3,684.14
You save:  L1,052.68
₲671,370.87
List Price:  ₲939,946.08
You save:  ₲268,575.20
$U3,917.97
List Price:  $U5,485.31
You save:  $U1,567.34
zł359.24
List Price:  zł502.95
You save:  zł143.71
Already have an account? Log In

Transcript

Hello, in this video, we are going to cover a limiting data selection. So what do I mean by that? So we've got this little application that just basically selects all of the data from the users table. She's four rows at the moment and displays it. Imagine if you had thousand rolls in there. And you maybe it's a bunch of comments, like on a social networking website, usually don't have all comments loaded up straight away, who usually have let's say, 10, they scroll to the bottom or click a button to load the next and then the next and the next 10.

So limiting allows you to basically say I only want this many. So the first way that we can do it is by putting a keyword limit and this will just mean I want this many so if I put two, it will just give me these two. It will just give me the first two obviously if the the where condition, you can put that afterwards as well. But the limit will just apply to the ones that are successfully you know passing the where condition. So, this is one way of doing it a normal way of limiting is using the top command. So, using the top command is actually basically the same but I want to show you just in case you see online somewhere for example, so if I say talk to we work in Okay, ignore that one, then I think they've taken that out in the version of SQL, they're immune.

So you can you can just use the limit. The other one that you can use is row num. So row num, so remember if we have, you know, where, and we could say where let's say ID equals three foot and where ID equals three, your return basically just that one, but we can also say where Ronen for where so ID is less than or equal to three, and that will return all the ones are all less than or equal to free. So that's a you know, a bit more flexible than just saying is equal to A specific one. And what you can also do is I want to see if this actually works, because one second, the top didn't work. This will be interesting if this one works to another one for percentage, but let me just type it in and see if it works.

That I have updated my SQL recently. So you could have, you know, been, you know, not being the light, right? And if it didn't, it didn't matter. Who is a top 15? Rhonda? Nope.

Yes, that's no longer in the so we can get rid of that. So yeah, the two ways of really limiting is doing this way. So like basically checking the row number and you know, and so range, and also using a limit, we just get the first X number of rows. So that's how you limit data selections. If you have any questions, feel free to pop me a message. And as usual, I look for to seeing you in the next video

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.