Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?
"Bob Badour" <bbadour_at_golden.net> wrote in message
news:4uW2a.1409$0G3.168661119_at_mantis.golden.net...
> "Mikito Harakiri" <mikharakiri_at_ywho.com> wrote in message
> news:irT2a.10$O%2.40_at_news.oracle.com...
> > Not
> > for aggregates:
> >
> > PROJECTION*AGGREGATE != AGGREGATE*PROJECTION
> >
> > for example
> >
> > select distinct S from (
> > select distinct SUM(SAL) from emp
> > )
> >
> > is not the same as
> >
> > select distinct SUM(SAL) from (
> > select distinct SAL from emp
> > )
> >
> > where i'm using SQL with the "distinct" keyword merely as a surrogate
for
> > true relational syntax ("distinct" is redundant after aggregate
operation,
> > of course).
>
> Why should the sum of all salaries equal the sum of distinct salaries?
In set model they don't. In the bag model, however, we rewrite the above identity without the "distinct" keyword:
select S from (
select SUM(SAL) S from emp
)
is the same as
select SUM(SAL) from (
select SAL from emp
)
Once again, this means that PROJECTION and AGGREGATE commute in the bag model. Received on Thu Feb 13 2003 - 18:54:15 CST