Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL command
Message
From
25/11/2003 20:13:59
 
 
To
25/11/2003 19:33:20
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00853542
Message ID:
00853557
Views:
23
Hey Trey,

Thanks. It's a little different than the approach I was working on but I think I like yours better.

Aloha,

James
>you could order by a random number
>
Use theTable
>AFields(laStru)
>Create Cursor cuOutput From Array laStru
>
>** to get possible values
>Select Distinct zip, biztype ;
>  from theTable ;
>  into cursor cuZipBiztype
>
>Scan
>  lcZip=cuzipbiztype.zip
>  lcBiztype=cuzipbiztype.biztype
>
>  ** get 2 random records
>  Select top 2 zip, biztype, other1, other2, Rand()*10 as Ordering ;
>    from theTable ;
>    where zip=lcZip and biztype=lcBizType ;
>    order by Ordering ;
>    into cursor cuRandom
>
>  Select cuOutput
>  Append From DBF("cuRandom")
>EndScan
>
>
>
>
>>Hi All,
>>
>>We have a table with columns for zip and biztype. I need to randomly select two records per zip, per biztype. Is there a simple SQL command to do this?
>>
>>As usual thanks in advance for any help.
>>
>>Aloha,
>>
>>James
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform