|
|
|
Junior Member
      
Group: Forum Members
Last Login: 8/22/2008 11:30:56 AM
Posts: 22,
Visits: 41
|
|
Hi
I want to generate random integer numbers in Teradata.
In SQL, we have random function rand(), but it gives only the whole number between 0 and 1.
1. Like wise do we have any function to generate random numbers in Teradata?
2. And also similarly i want to select random records from a set of records in a table.
Does any one help me to do the above two tasks?
Thanks
Dileep
Dileep
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: Yesterday @ 7:30:07 AM
Posts: 197,
Visits: 611
|
|
Hello,
You can use following for random number:
- SELECT Random("min value", "max value"); e.g.: SELECT Random(0, 10);
For selecting random rows, you can use:
- SELECT * from Table1 Sample 10;
HTH.
Regards,
Adeel
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 8/22/2008 11:30:56 AM
Posts: 22,
Visits: 41
|
|
Does the min and max values include in the range??
Thanks
Dileep
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: Yesterday @ 7:30:07 AM
Posts: 197,
Visits: 611
|
|
Yes, you could have tested it yourself as well. :)
For verification, try this several times: "SELECT Random(1, 2);"
Regards,
Adeel
|
|
|
|
|
Junior Member
      
Group: Forum Members
Last Login: 8/22/2008 11:30:56 AM
Posts: 22,
Visits: 41
|
|
it's ok .... for time being i don't have the teradata sql assistant installed in my machine... i will get it soon.
can i have the syntax for creating an user defined function in teradata?
i want to include the above statements in a function and re-use that function.
Thanks
Dileep
|
|
|
|