How about something like this?

SET VAR vtablerows INTEGER = NULL
SELECT COUNT(*) INTO vtablerows FROM tablename
SET VAR vmaxvalue INTEGER = NULL
SET VAR vmaxvalue = (RANDOM(.vtablerows))
SELECT * FROM tablename WHERE COUNT = .vmaxvalue
RETURN

Jeff Richardson | Project Manager, Asset Verification Services (AVS)
DMA – DuCharme, McMillen & Associates, Inc. | 6610 Mutual Drive, Fort Wayne, IN 
46825
Cell: 724-366-1724
Connect: [email protected]<mailto:[email protected]> | 
Website<http://www.dmainc.com/> | 
LinkedIn<https://www.linkedin.com/company/ducharme-mcmillen-&-associates> | 
Twitter<https://twitter.com/DMATAX> | 
Facebook<https://www.facebook.com/DMAtaxservices>
___________________________________________________________
ATTENTION: This message and all attachments are PRIVATE, and may contain 
information that is CONFIDENTIAL and PRIVILEGED.  If you have received this 
message in error, please notify the sender by reply e-mail and delete the 
message immediately.

From: [email protected] [mailto:[email protected]] On Behalf Of 
Dan Goldberg
Sent: Tuesday, August 9, 2016 1:44 PM
To: [email protected]
Subject: RE: [RBASE-L] - pick a random row

I remembered there is column alias like

bro all from tablename where #2 = value

which will look at column# 2.

Wonder if there is one for row?

Dan Goldberg

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Dan Goldberg
Sent: Tuesday, August 9, 2016 10:42 AM
To: [email protected]<mailto:[email protected]>
Subject: RE: [RBASE-L] - pick a random row

I wish it was that easy.

If I remember correctly there is a way to select a row by the row number?

Then I could do.

Select all from tablename where row_number = 1

If can remember the syntax for that maybe I can do a random on that.

Dan Goldberg

From: karentellef via RBASE-L [mailto:[email protected]]
Sent: Tuesday, August 9, 2016 10:25 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: [RBASE-L] - pick a random row

would adding "and limit = 1" do the trick?  It isn't quite random because I 
believe it would always select the first physical row that matches the where 
clause.

Karen



-----Original Message-----
From: Dan Goldberg <[email protected]<mailto:[email protected]>>
To: rbase-l <[email protected]<mailto:[email protected]>>
Sent: Tue, Aug 9, 2016 12:06 pm
Subject: [RBASE-L] - pick a random row
I have a select statement that I need to create that will pick one random row 
based on the where clause.

SELECT *FROM averyweb_items WHERE  iditemscategory = 4 AND  itemsstatus = 1

I can do a random function but not sure on how to implement it.

I cannot figure out what I need to do. Any help is appreciated.

TIA



Dan Goldberg
MIS Manager
Lance Camper Mfg. Corp
(661) 949-3322 Ext 252
www.lancecamper.com<http://www.lancecamper.com/>


--
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

ATTENTION: This message and all attachments are PRIVATE, and may contain 
information that is CONFIDENTIAL and PRIVILEGED. If you have received this 
message in error, please notify the sender by reply e-mail and delete the 
message immediately.

-- 
You received this message because you are subscribed to the Google Groups 
"RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to