Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with SQL command
Message
From
25/11/2003 19:33:20
 
 
To
25/11/2003 19:10:50
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00853542
Message ID:
00853544
Views:
14
This message has been marked as the solution to the initial question of the thread.
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
Insanity: Doing the same thing over and over and expecting different results.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform