serafim@nada.kth.se (Serafim Dahl) (01/23/89)
Sorry about the last letter. The first two lines were missing. In a relational database there is a base relation: Emp ((name), sal, mgr, dept) where Emp=employee, sal=salary, mgr=manager, dept=department the following query: a) select avg(sal) from Emp where dept in (select dept from Emp where name = 'Smith') gives the answer '8383.333'. Examining the query, breaking it down as follows: b) Select dept from Emp where name='Smith'; (giving the answer 'food') select avg(sal) from Emp where dept='food'; gives the answer '7795.833'. It turns out that, in query a all duplicates in sal are eliminated, while in b they quite correctly are not eliminated. /serafim@nada.kth.se