Re: does a table always need a PK?
From: Mikito Harakiri <mikharakiri_at_ywho.com>
Date: Wed, 3 Sep 2003 14:18:59 -0700
Message-ID: <t1t5b.23$eu1.263_at_news.oracle.com>
)
where rn in (
) where rn >= (rowcount+1)/2
) or rn in (
) where rn <= (rowcount+1)/2
) Received on Wed Sep 03 2003 - 23:18:59 CEST
Date: Wed, 3 Sep 2003 14:18:59 -0700
Message-ID: <t1t5b.23$eu1.263_at_news.oracle.com>
"Mikito Harakiri" <mikharakiri_at_ywho.com> wrote in message
news:4Ls5b.22$eu1.271_at_news.oracle.com...
> MEDIAN is redundant:
select sum(sal)/count(1) from (
select
sal, (select count(1)+1 from emp ee where ee.sal < e.sal) rnfrom emp e
)
where rn in (
select min(rn) from (
select (select count(1)+1 from emp ee where ee.sal < e.sal) rn, (select count(1) from emp) rowcount from emp e
) where rn >= (rowcount+1)/2
) or rn in (
select max(rn) from (
select (select count(1)+1 from emp ee where ee.sal < e.sal) rn, (select count(1) from emp) rowcount from emp e
) where rn <= (rowcount+1)/2
) Received on Wed Sep 03 2003 - 23:18:59 CEST