phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Terrell <>
Subject Re: Random rows
Date Tue, 28 Mar 2017 22:10:01 GMT
Here's what I do in one of my applications.  A two-step process minimum
(three if you get a total row count first):

upsert into DEMO(KEY_FIELD_1,KEY_FIELD_2,"random_sample" boolean) select

Where in this example, I want to randomly select 50 rows from a table
containing 1,000 rows. It will only be approximate.  The ".0" is added to
make sure the division does not yield an int.  You can replace the division
with any ratio you like.

Anyway, after doing the above upsert select, I can query for the random
rows like this:

select * from DEMO("random_sample" boolean) where "random_sample" is true

That's the best I could come up with using Phoenix 4.6.0.

Hope this helps,

On Tue, Mar 28, 2017 at 2:18 PM, Mike Prendergast <> wrote:

> Any suggestion on how I could obtain a random set of rows in Phoenix? I'm
> looking to get a sample set spread across all regions for testing purposes.
> Thanks in advance
> Michael Prendergast
> *iota IT*
> Vice President / Software Engineer
> (cell)     703.594.1053 <(703)%20594-1053>
> (office)  571.386.4682 <(571)%20386-4682>
> (fax)     571.386.4681 <(571)%20386-4681>
> This e-mail and any attachments to it are intended only for the identified
> recipient(s). It may contain proprietary or otherwise legally protected
> information of Iota IT, Inc. Any unauthorized distribution, use or
> disclosure of this communication is strictly prohibited. If you have
> received this communication in error, please notify the sender and delete
> or otherwise destroy the e-mail and all attachments immediately.

View raw message