Sql Random Number Between 1 and 100

To get random number in sql we use rand() function. But rand() funcition returns decimally random between 0 and 1. If we want to get between 1 and 100 we must multiply the number with top value. Then we must round the number. To round a number we can use 3 different methods. The first one floor method rounds the number to the integer floor value. The second one ceiling value, roundes to ceiling and the third one round method.

Example 1 : Show random number between 0 and 100;

Example 2 : Show random number between 1 and 100;

Example 3 : Show random number between 50 and 100;

Example 4 : Show random number between 20 and 80;

YOU MAY WANT TO SEE OUR ALL EXAMPLES PAGE, THEN CLICK HERE

2 Comments

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: