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
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
Hey Ozer,
How about dynamic queries?
2010/10/2 Ozer, Pam po...@automotive.com
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
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()
Ozer, Pam po...@automotive.com 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
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
--
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:
--
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, Oct
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 post).
: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
On Tue, 20 Oct 2009 16:49:17 -0300
Nahuel Alejandro Ramos nahue...@gmail.com 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
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:
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
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
]
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 the table T1 up
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
am Sat, dem 18.11.2006, um 23:02:33 +0530 mailte Rajesh Kumar Mallah folgendes:
select bigint_column from your_table 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
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 bigint_column from your_table order by random() limit 1;
This query will tend to get slower as the table grows because of the
sorting.
Right.
it
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 bigint_column from your_table
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
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 bigint_column from your_table order by random() limit 1;
Andreas
--
Andreas
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
within
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
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 table
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 * FROM
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
desired
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]
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
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
---
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 some output. Is
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();
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 some
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
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. Why
34 matches
Mail list logo