Re: Self Joins and optimization

From: Vadim Tropashko <vadimtro_invalid_at_yahoo.com>
Date: 11 May 2007 15:59:54 -0700
Message-ID: <1178924393.996377.191150_at_y80g2000hsf.googlegroups.com>


On May 11, 3:50 pm, Vadim Tropashko <vadimtro_inva..._at_yahoo.com> wrote:
> What if you want to ask salary rank of all the people in the
> department 10, or a single person in a big corporation? The self-join
> query is easily adjusted to the new requirements:
>
> SELECT E1.ENAME, E1.SAL, COUNT(*) RNK
> FROM EMP E1, EMP E2
> WHERE E2.SAL <= E1.SAL
> AND E1.ename = 'BLAKE'
> GROUP BY E1.ENAME, E1.SAL
Moreover, one can easily accomodate the above query to answer a query like
"what is the salary rank of Blake among all the employees in the department 40"
This query is legitimate even though Blake doesn't belong to department 40, while in analytics case you would be forced to artificially add Blake to the department 40 before firing analytics query... Received on Sat May 12 2007 - 00:59:54 CEST

Original text of this message