Re: Random Number
Posted in 1996
In Article<4ipv2b$ku2@cssun.mathcs.emory.edu>, <SOHO!dpsanjay@whitestone.raileurope.com> writes: > > Does any one have an algorithm to get a randow row from a table ? > > e.g. We want to pick up a random order from orders table for all the > transaction made today ? > > Thanx a lot for your help > ____________ > Sanjay Kumar Email: skumar@raileurope.com > Rail Europe Inc. > 226 Westchester Ave | Office : (914) 681 3296 > White Plains, NY 10604 | Fax : (914) 682 5236 > If we're talking 4gl, try this! marco. ----- cut here ----- int get_rand(); int start_rand(); int say_seed(); int get_seed(); unsigned int seed=1; get_rand() { long i,j; popint(&i); seed=(0x8088405*seed+1) & 0xFFFF; j=seed % i; retint(j); return(1); } start_rand() { int i; popint(&i); seed=i; return(0); } say_seed() { retint(seed); return(1); } get_seed() { int i; i=(time(NULL)) & 0xFFFF; retint(i); return(1); } ----- end cut ----- ____________________________________________________________________________ rem radioterapia, which I immeritately manage, seldom agrees with what I say marco greco (Catania, Italy) Work: marcog@ctonline.it rem radioterapia 39 95 447828 fax 446558 (was mar.greco@agora.stm.it) Achea 39 95 503117