Re: Unknown SQL

From: Vadim Tropashko <nospam_at_newsranger.com>
Date: Sat, 21 Jul 2001 23:26:59 GMT
Message-ID: <x_aR6.5659$rn5.276726_at_www.newsranger.com>


In article <1BaR6.5617$rn5.275065_at_www.newsranger.com>, Mikito Harakiri says...
>
>In article <asaR6.5598$rn5.274313_at_www.newsranger.com>, Vadim Tropashko says...
>>
>>Which prompts a natural question "how easy are aggregate/group by queries in
>>object querying"? Last time your example with car and wheels gave us some
>>flavour what object querying is. How about
>>
>>select sum(sal) from emp group by dept
>>
>>?
>
>Your question is very similar to Codd's famous "find all employees who earn more
>than their managers". This was said before "group by" was introduced, i guess.
>With "group by" the query becomes: "find all managers whose salary is more sum
>of all their employees".
>
:-)

To be pedantic, the last query doesn't necessarily need "group by", as it can be formulated as correlated subquery (unless you want to display those sums for each manager, not just compare). Furthermore, "group by" can be eliminated altogether by using subqueries in the columns (which I kind of dislike). Column subqueries trick maybe a clue how to write object analog of "group by" query. Received on Sun Jul 22 2001 - 01:26:59 CEST

Original text of this message