Re: How to select a random row from each sub table after "group by"?
From: yossarian <yossarian99_at_operamail.com>
Date: Thu, 04 Jun 2009 11:35:03 +0200
Message-ID: <4a279547$0$709$5fc30a8_at_news.tiscali.it>
yossarian wrote:
)
group by
class
; Received on Thu Jun 04 2009 - 04:35:03 CDT
Date: Thu, 04 Jun 2009 11:35:03 +0200
Message-ID: <4a279547$0$709$5fc30a8_at_news.tiscali.it>
yossarian wrote:
> I don't know if I have understood correctly what you ask, anyway here's
> my 2 cents
A better (?) solution with same data and table structure as above:
select
class,
max(data1) keep (dense_rank first order by rnd),
max(data2) keep (dense_rank first order by rnd)
from
(
select
class, data1, data2, dbms_random.random rnd from x
)
group by
class
; Received on Thu Jun 04 2009 - 04:35:03 CDT