Re: Extending my question. Was: The relational model and relational algebra - why did SQL become the industry standard?
Date: 12 Mar 2003 00:04:53 +0100
Message-ID: <3e6e6b95.0_at_news.ruca.ua.ac.be>
Mikito Harakiri wrote:
>"Jan Hidders" <jan.hidders_at_REMOVE.THIS.ua.ac.be> wrote in message
>news:3e6e57e3.0_at_news.ruca.ua.ac.be...
> What I meant was:
>>
>> >> SELECT f(x)
>> >> FROM
>> >> ( SELECT g(y)
>> >> FROM y IN Y ) AS x
>>
>> and
>>
>> >> SELECT f(g(y))
>> >> FROM Y AS y
>
>In set model
>
>SELECT f(x) as Fx, y
>FROM
> ( SELECT g(y) as x, y
> FROM Y)
>
>reduces to
>
>SELECT f(g(y)) as FGy, y
>FROM Y
Absolutely. However, that rule doesn't apply because aggregation functions
are used and a group by is included. Just for clarity here is the reduction
that you have to derive, in a more proper notation:
SELECT f(x) AS fx, COUNT(*) AS cnt
FROM
( SELECT g(y) AS fy, COUNT(*) AS cnt
FROM Y AS y
GROUP BY fy ) AS x
GROUP BY fx
to
SELECT f(g(y)) AS fx, COUNT(*) AS cnt
FROM Y AS y
GROUP BY fx
- Jan Hidders