Sql Random Number Between 1 and 1000

Sql Random Number Between 1 and 1000
Written by Thomas Brown

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 1000 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 1000;

Example 2 : Show random number between 1 and 1000;

Method-2

Example 3 : Show random number between 500 and 1000;

Example 4 : Show random number between 200 and 1000;

Also you can see the related posts below….

Sql random number between 1 and 100

Sql Random Number Between 0 and 1 

Mysql Random Number Between 1 and 100

Leave a Comment

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

%d bloggers like this: