What about dynamic queries?
From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On
Behalf Of Dmitriy Igrishin
Sent: Saturday, October 02, 2010 6:40 AM
To: Ozer, Pam
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Random sort with distinct
Hey Ozer,
How about
"Ozer, Pam" writes:
> Select Distinct VehicleMake, VehicleModel
> From VehicleYearMakeModelTrim
> Order by random()
> Limit 10;
> I don't want to bring back the random number I just want the sort order
> to be random. How can I sort randomly? This query breaks because
> random() is not in the se
This runs fine on my 8.4 install. What version are you using and what
error message are you getting?
--Lee
On 10/01/2010 04:51 PM, Ozer, Pam wrote:
I have the following query
Select Distinct VehicleMake, VehicleModel
From VehicleYearMakeModelTrim
Order by random()
Hey Ozer,
How about dynamic queries?
2010/10/2 Ozer, Pam
> I have the following query
>
>
>
> Select Distinct VehicleMake, VehicleModel
>
> From VehicleYearMakeModelTrim
>
> Order by random()
>
> Limit 10;
>
>
>
> I don’t want to bring back the random number I just want the sort order to
> be
I have the following query
Select Distinct VehicleMake, VehicleModel
>From VehicleYearMakeModelTrim
Order by random()
Limit 10;
I don't want to bring back the random number I just want the sort order
to be random. How can I sort randomly? This query breaks because
random() is not in the
Nahuel Alejandro Ramos wrote:
> Hi all,
> I was searching for a sequence (for serials) that let me use a random
> unique number ID on a Primary Key or a simple index.
> I have not found a solution so I have done it by myself. I would like to
> share it so here it is:
Here's what I'm using:
ht
On Tue, 20 Oct 2009 16:49:17 -0300
Nahuel Alejandro Ramos wrote:
> Hi all,
> I was searching for a sequence (for serials) that let me use a
> random unique number ID on a Primary Key or a simple index.
> I have not found a solution so I have done it by myself. I would
> like to share it so he
:D, Yeah, i know. Its only an example. We are using this algorithm to give a
random unique Id to our clients. The need was to give a PK absolute
independent of time. Thanks to Ivan, for the pseudo-random posted, I am
looking it.
Regards...
Nahuel Alejandro Ramos.
On Tue, Oct 20, 2009 at 5:0
Suit yourself, of course, but the numbers on my credit cards are far,
far from random :)
Nahuel Alejandro Ramos wrote:
> Yes. I looked this solution but it is not a "only numbers" ID. I would
> like a random unique "number" Id. For example: generate a credit number
> randomly (like the example I
Yes. I looked this solution but it is not a "only numbers" ID. I would like
a random unique "number" Id. For example: generate a credit number randomly
(like the example I post).
I used to insert an MD5 field but this time I need "only numbers" Id.
Regards...
Nahuel Alejandro Ramos.
On Tue
Nahuel Alejandro Ramos wrote:
> Hi all,
> I was searching for a sequence (for serials) that let me use a random
> unique number ID on a Primary Key or a simple index.
> I have not found a solution so I have done it by myself. I would like
> to share it so here it is:
>
> --
Hi all,
I was searching for a sequence (for serials) that let me use a random
unique number ID on a Primary Key or a simple index.
I have not found a solution so I have done it by myself. I would like to
share it so here it is:
--
-- Create language "plpgsql"
-- --
On 14.06.2007, at 22:40, Campbell, Lance wrote:
I have a web application that is used to create web surveys and web
forms. Users can create any number of surveys or forms at any time.
The primary key on one of my tables defines the ID for any given
form or
survey. I do NOT want the number s
EMAIL PROTECTED]
Sent: Thursday, June 14, 2007 8:26 AM
To: Campbell, Lance
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Random Unique Integer
On Thu, Jun 14, 2007 at 08:08:26AM -0500, Campbell, Lance wrote:
> I have a table T1. It contains a field called F1. Is there a way for
> me to set
On Thu, Jun 14, 2007 at 08:08:26AM -0500, Campbell, Lance wrote:
> I have a table T1. It contains a field called F1. Is there a way for
> me to set the table T1 up such that F1 can be populated with a random
> integer such that F1 is a unique integer?
What problem are you trying to solve? The s
I have a table T1. It contains a field called F1. Is there a way for
me to set the table T1 up such that F1 can be populated with a random
integer such that F1 is a unique integer? I would rather not create a
stored procedure.
Thanks,
Lance Campbell
Project Manager/Software Archit
On 11/18/06, A. Kretschmer <[EMAIL PROTECTED]> wrote:
am Sat, dem 18.11.2006, um 23:02:33 +0530 mailte Rajesh Kumar Mallah
folgendes:
> >select from order by random() limit 1;
>
> This query will tend to get slower as the table grows because of the
> sorting.
Right.
>
> it possible to get
am Sat, dem 18.11.2006, um 23:02:33 +0530 mailte Rajesh Kumar Mallah folgendes:
> >select from order by random() limit 1;
>
> This query will tend to get slower as the table grows because of the
> sorting.
Right.
>
> it possible to get a row from a random offset
> how about
>
> select fr
On 11/17/06, A. Kretschmer <[EMAIL PROTECTED]> wrote:
am Thu, dem 16.11.2006, um 16:31:14 -0200 mailte Ezequias Rodrigues da
Rocha folgendes:
> Hi list,
>
> I have a bigint collumn and I would like to generate a random number
within the
> numbers of my column.
select from order by random()
On 11/16/06, A. Kretschmer <[EMAIL PROTECTED]> wrote:
am Thu, dem 16.11.2006, um 16:31:14 -0200 mailte Ezequias Rodrigues da
Rocha folgendes:
> Hi list,
>
> I have a bigint collumn and I would like to generate a random number
within the
> numbers of my column.
select from order by random() l
On Thu, Nov 16, 2006 at 06:54:42PM -0200, Ezequias Rodrigues da Rocha wrote:
> My bigint field has 20,000 numbers and I'd like to make real random (used
> like lottery).
If you want _real_ random, you have to use a non-computer source for
your randomness. The best you get on a computer is pseudo-
Just another question. I can trust on this random number ? The rule to it is
quite tested ?
I am thinking in implementing a function that return allways a random
number. What do you think of the trust of this function (random()) ?
My bigint field has 20,000 numbers and I'd like to make real rand
Thank you so much andreas.
Regards
http://ezequiasrocha.blogspot.com
2006/11/16, A. Kretschmer <[EMAIL PROTECTED]>:
am Thu, dem 16.11.2006, um 16:31:14 -0200 mailte Ezequias Rodrigues da
Rocha folgendes:
> Hi list,
>
> I have a bigint collumn and I would like to generate a random number
withi
am Thu, dem 16.11.2006, um 16:31:14 -0200 mailte Ezequias Rodrigues da Rocha
folgendes:
> Hi list,
>
> I have a bigint collumn and I would like to generate a random number within
> the
> numbers of my column.
select from order by random() limit 1;
Andreas
--
Andreas Kretschmer
Kontakt: H
Hi list,
I have a bigint collumn and I would like to generate a random number within
the numbers of my column.
Is it possible ?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atenciosamente (Sincerely)
Ezequias Rodr
> I'm running into a performance problem when considering the following
> scenario: I have a fairly large table (1mio rows) related to other smaller
> tables (between 100 and 1 rows) and would like to retrieve the joined
> data (through a view) in random order. In order to do so, the main tabl
On Thu, 1 Aug 2002, [iso-8859-1] Cédric Dufour wrote:
> *
> * 2.
> *
> BEGIN;
> SET CONSTRAINTS ALL DEFERRED;
> CREATE TEMP TABLE tmp_Large AS SELECT * FROM tb_Table;
> DELETE FROM tb_Large; -- won't work; RI violation on foreign key
> 'tb_Foo(FK_Large)'
> INSERT INTO tb_Large SELECT * F
Hello to all of you,
I'm running into a performance problem when considering the following
scenario: I have a fairly large table (1mio rows) related to other smaller
tables (between 100 and 1 rows) and would like to retrieve the joined
data (through a view) in random order. In order to do so,
Jie,
> How I can return random N rows from my select stmt?
> like:
> e.g. what my selectee is a set of 1000 rows, I want randomly
> pickup 100 of 1000.
You'd have to do it inside a function or external program, and copy the
rows to a temporary table (which is what you'd return to the user).
Th
Hi!
> How I can return random N rows from my select stmt?
> like:
> e.g. what my selectee is a set of 1000 rows, I want randomly
> pickup 100 of 1000.
use the LIMIT clause
example
SELECT * FROM test_table LIMIT 100;
you can also use the OFFSET clause to skip to n row and the fetch the n
desi
How I can return random N rows from my select stmt?
like:
e.g. what my selectee is a set of 1000 rows, I want randomly
pickup 100 of 1000.
thanks.
Jie LIANG
St. Bernard Software
10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873
[EMAIL PROTECTED]
www.stbernard.
On Wed, Mar 07, 2001 at 12:50:36PM +0100, Tomek Zielonka wrote:
> On Mon, Mar 05, 2001 at 02:12:15PM -0500, Jelle Ouwerkerk wrote:
> > Hi
> >
> > What would be the best way to select a random row from a result set?
> >
>
> Here's my approach. It allows to get random row from the table, not from
On Mon, Mar 05, 2001 at 02:12:15PM -0500, Jelle Ouwerkerk wrote:
> Hi
>
> What would be the best way to select a random row from a result set?
>
> Possibilities:
>
> 1) o get the total number of rows using count()
>o generate a random number between 1 and the total
>o select the n'th ro
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> > But random returns a random value from 0-1, right? How does that work
> > in ORDER BY?
>
> What's the problem? Each row gets a different random value, then we
> sort.
Oh, I see. Nifty. I am used to seeing a column name or number in ORDER
BY. W
Bruce Momjian <[EMAIL PROTECTED]> writes:
> But random returns a random value from 0-1, right? How does that work
> in ORDER BY?
What's the problem? Each row gets a different random value, then we
sort.
regards, tom lane
---(end of broadcast)---
> Bruce Momjian <[EMAIL PROTECTED]> writes:
> >> Jelle Ouwerkerk <[EMAIL PROTECTED]> writes:
> > Also, is there a way to randomize the order of a result set?
> >>
> >> There's always
> >> SELECT * FROM foo ORDER BY random();
>
> > However:
> > test=> select * from pg_class order by random();
On Mon, 5 Mar 2001, Bruce Momjian wrote:
> > Jelle Ouwerkerk <[EMAIL PROTECTED]> writes:
> > > Also, is there a way to randomize the order of a result set?
> >
> > There's always
> > SELECT * FROM foo ORDER BY random();
> >
>
> How does that work?
>
> test=> select random();
>
Bruce Momjian <[EMAIL PROTECTED]> writes:
>> Jelle Ouwerkerk <[EMAIL PROTECTED]> writes:
> Also, is there a way to randomize the order of a result set?
>>
>> There's always
>> SELECT * FROM foo ORDER BY random();
> However:
> test=> select * from pg_class order by random();
> does return s
> Jelle Ouwerkerk <[EMAIL PROTECTED]> writes:
> > Also, is there a way to randomize the order of a result set?
>
> There's always
> SELECT * FROM foo ORDER BY random();
>
How does that work?
test=> select random();
random
---
Jelle Ouwerkerk <[EMAIL PROTECTED]> writes:
> Also, is there a way to randomize the order of a result set?
There's always
SELECT * FROM foo ORDER BY random();
regards, tom lane
---(end of broadcast)---
TIP 3: if pos
Hi
What would be the best way to select a random row from a result set?
Possibilities:
1) o get the total number of rows using count()
o generate a random number between 1 and the total
o select the n'th row using OFFSET
2) o get the total number of rows using count()
o generate a ran
41 matches
Mail list logo