Skip to content
Related Articles

Related Articles

Improve Article
Rnd() and Round Function in MS Access
  • Last Updated : 02 Sep, 2020

1. Rnd() Function :
Rnd() function return the random number.if we want to generate a number between 0 to 1 then use only Rnd. Otherwise, if we want to generate a number between a range then we will use the formula Int ((upperbound – lowerbound + 1) * Rnd + lowerbound).

Syntax :

  • If we want to generate between 0 to 1 –
    Rnd 
  • If we want to generate in a range –
    Int((upperbound - lowerbound + 1) * Rnd + lowerbound) 

Example-1 :

SELECT Int ((10 - 1 + 1) * Rnd + 1) AS RandNumBetween1and10;

Output –

RandNumBetween1and10
8

Example-2 :



SELECT Rnd AS RandNumBetween0and1;

Output –

RandNumBetween0and1
0.705547511577606

2. Round() Function :
Round() function returns rounds a number to a specified number of decimal places.In this function we will pass an expression and the second parameter will be decimal places till that the number will be rounded.

Note :
If the number ends with 5 then this function rounded last digits as even number.

Syntax :

Round(expression, decimal_places)

Example-1 :

SELECT Round(23.67, 1) As round;

Output –

round
23.7

Example-2 :

SELECT Round(45.65, 1) As round;

Output –

round
45.6
My Personal Notes arrow_drop_up
Recommended Articles
Page :