Hi,
I have a view in which I want to randomly assign values if certain
conditions hold. I was getting surprising results. Here is a (very)
simplified version of the view, which seems to indicate the problem:
CREATE OR REPLACE VIEW test_view AS
SELECT
CASE
WHEN random()
On Feb 23, 2009, at 2:09 PM, Jessi Berkelhammer wrote:
Hi,
I have a view in which I want to randomly assign values if certain
conditions hold. I was getting surprising results. Here is a (very)
simplified version of the view, which seems to indicate the problem:
CREATE OR REPLACE VIEW
Jessi,
should the function not look like this???
CREATE OR REPLACE VIEW test_view AS
SELECT
CASE
WHEN random() .3 THEN '1'
WHEN random() .5 THEN '2'
ELSE '3'
END AS test_value
FROM client;
On Feb 23, 2009, at 5:09 PM,
ries van Twisk wrote:
Jessi,
should the function not look like this???
CREATE OR REPLACE VIEW test_view AS
SELECT
CASE
WHEN random() .3 THEN '1'
WHEN random() .5 THEN '2'
ELSE '3'
END AS test_value
FROM client;
actually, I'd think that should be
Or perhaps:
CREATE OR REPLACE VIEW test_view AS
SELECT (random()*3)::int as test_value;
At least in this case, that should give the same result.
in this case 1/3 should be 1, 1/3 = 2 1/3=3
in your case 1/3 = 1, 1/2 the remainder (1/2 * 2/3 = 1/3) = 2, remaining 1/3 = 3
Although I'm guessing
John R Pierce pie...@hogranch.com writes:
ries van Twisk wrote:
should the function not look like this???
CREATE OR REPLACE VIEW test_view AS
SELECT
CASE
WHEN random() .3 THEN '1'
WHEN random() .5 THEN '2'
ELSE '3'
END AS test_value
FROM client;
actually, I'd think that
Steve Atkins wrote:
On Feb 23, 2009, at 2:09 PM, Jessi Berkelhammer wrote:
Hi,
I have a view in which I want to randomly assign values if certain
conditions hold. I was getting surprising results. Here is a (very)
simplified version of the view, which seems to indicate the problem:
On Mon, Feb 23, 2009 at 5:16 PM, raf r...@raf.org wrote:
this looks like an attempt to understand the monty hall problem.
http://en.wikipedia.org/wiki/Monty_Hall_problem
except that there's no goat :(
And what database management system can be complete without a goat? :)
--
Sent via