Hi again
I'm working on a report that needs to select all records where the in that employees USER_DEF8 field (user define) matches a random number each time the report runs
Example
When the report runs if the random number is 7 then I would get a list with Bob and James.
I have this code from the internet and it works at generating a random number I'm just no sure how to get it as part of my select statement
Here is my select statement
In addition I would also liek to generate a random number for each record returned 5-6 characters long
FINAL OUTPUT (if random number is 7)
Thanks in advance for any help with this
RJL
I'm working on a report that needs to select all records where the in that employees USER_DEF8 field (user define) matches a random number each time the report runs
Example
Code:
Emp Name USER_DEF8
Bob Smint 7
James King 7
Eric Jones 1
Tim Tucker 5
When the report runs if the random number is 7 then I would get a list with Bob and James.
I have this code from the internet and it works at generating a random number I'm just no sure how to get it as part of my select statement
Code:
DECLARE @RandomNumber float
DECLARE @RandomInteger int
DECLARE @MaxValue int
DECLARE @MinValue int
SET @MaxValue = 9
SET @MinValue = 0
SELECT @RandomNumber = RAND()
SELECT @RandomInteger = ((@MaxValue + 1) - @MinValue) * @RandomNumber + @MinValue
SELECT @RandomNumber as RandomNumber, @RandomInteger as RandomInteger;
Here is my select statement
Code:
SELECT
UP.USER_NAME,
UP.DESCRIPTION
FROM USER_PROFILE UP WITH(NOLOCK)
WHERE
UP.USER_DEF8 IN(
In addition I would also liek to generate a random number for each record returned 5-6 characters long
FINAL OUTPUT (if random number is 7)
Code:
USER_NAME DECRIPTION RANDOM_NUM
BMISTH Bob Smint 597521
JKING James King 692758
Thanks in advance for any help with this
RJL